ESP32 - Pushing a Varaible out to multiple GPIO pins using registers

How to output a variable directly to GPIO pins ... i.e. in parallel.

This can be done using the ESP32's registers.

// sending a variable to GPIO pins Bitwise register style

// create a parallel GPIO bus using GPIO 12,13,14,15 i.e. must be consecutive pins
#define PARALLEL_0  12

int RGBled=000; // demo RGB connected to Gpio pin 12,13,14,15

void setup() {

// set the digital pin as outputs:
 pinMode(12, OUTPUT);  pinMode(13, OUTPUT);  pinMode(14, OUTPUT);  pinMode(15, OUTPUT); 

void loop() {
parallel_write(RGBled);  //output gpio 12,13,14,15(extra) as a bitwise operation


void parallel_write(uint8_t value) {
  uint32_t output = (REG_READ(GPIO_OUT_REG) & ~(0xFF << PARALLEL_0)) | (((uint32_t)value) << PARALLEL_0);

Using this method simplifies/illiminates multiple writes to each GPIO in turn.