#define clkPin 12
#define dataPin 13
#define latchPin 15
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(latchPin, OUTPUT);
pinMode(clkPin, OUTPUT);
pinMode(dataPin, OUTPUT);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clkPin, MSBFIRST, 0);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
}
void loop() {
delay(10);
int8_t i, j;
byte state = 0;
for(i=7; i>=0; i--){
for(j=0; j<i; j++){
byte temp = state;
bitWrite(temp, j, 1);
shiftOut(dataPin, clkPin, MSBFIRST, temp);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(50);
}
bitWrite(state, i, 1);
shiftOut(dataPin, clkPin, MSBFIRST, state);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(100);
}
}