// ST_CP pin 12
const int latchPin = GPIO_NUM_19;
// SH_CP pin 11
const int clockPin = GPIO_NUM_21;
// DS pin 14
const int dataPin = GPIO_NUM_18;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void shiftOut2(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;
for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
digitalWrite(clockPin, HIGH);
delay(30);
digitalWrite(clockPin, LOW);
delay(30);
digitalWrite(latchPin, LOW);
delay(5);
digitalWrite(latchPin,HIGH );
}
}
void loop() {
for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
// ST_CP LOW to keep LEDs from changing while reading serial data
//digitalWrite(latchPin, LOW);
// Shift out the bits
Serial.println(numberToDisplay);
shiftOut2(dataPin, clockPin, MSBFIRST, numberToDisplay);
// ST_CP HIGH change LEDs
///digitalWrite(latchPin, HIGH);
delay(1000);
}
}
ERC Warnings
not1:IN: Input pin not driven