#define ds 15
#define latch 2
#define shift 4
// const int ds = 15;
// const int latch = 2;
// const int shift = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(ds, OUTPUT);
pinMode(latch, OUTPUT);
pinMode(shift, OUTPUT);
}
// int pattern = 0b1010101001010101;
// int pattern = 0xf000;
void loop() {
for (int i = 1; i <= 32768; i = i * 2) {
digitalWrite(latch, LOW);
shiftOut(ds, shift, LSBFIRST, i >> 8);
shiftOut(ds, shift, LSBFIRST, i);
digitalWrite(latch, HIGH);
delay(50);
}
for (int i = 16384; i >= 2; i = i / 2) {
digitalWrite(latch, LOW);
shiftOut(ds, shift, LSBFIRST, i >> 8);
shiftOut(ds, shift, LSBFIRST, i);
digitalWrite(latch, HIGH);
delay(50);
}
// digitalWrite(latch, LOW);
// shiftOut(ds, shift, MSBFIRST, pattern);
// digitalWrite(latch, HIGH);
// delay(1000);
// pattern = ~pattern; // Invert the pattern
// put your main code here, to run repeatedly:
// delay(10); // this speeds up the simulation
}