Hi all,
I am using 74hc595 in several projects where I need more I/O and always worked fine using arduino pro mini or arduino mega. Now I connected same 2 of 74hc595 to an esp32 and does not work.
Is there any special things to do for esp32?
Wiring is exactly the same like here https://www.arduino.cc/en/tutorial/ShiftOut on chapter 2 (Connect the 2 registers.). If I use this with an arduino mega on pins 10,9,8 (see commented in code) is working perfect.
Then I replace arduino mega with esp32 and using pins 23,18,5 and does nothing. I get in serial monitor on/off prints but nothing changes to the relays.
Code
int SER_Pin = 23;//10; //pin 14 on 75hc595 //data pin
int RCLK_Pin = 18;//9; //pin 12 //latch
int SRCLK_Pin = 5;//8; //pin 11 //clock
#define number_of_74hc595s 2
#define numOfRegisterPins number_of_74hc595s * 8
boolean registers[numOfRegisterPins];
void setup() {
Serial.begin(9600);
pinMode(SER_Pin, OUTPUT);
pinMode(RCLK_Pin, OUTPUT);
pinMode(SRCLK_Pin, OUTPUT);
clearRegisters();
writeRegisters();
}
void clearRegisters() {
for (int i = numOfRegisterPins -1; i >= 0; i--) {
registers[i] =HIGH;
}
}
//Set and display registers
//Only call after all values are set how you would like
void writeRegisters() {
digitalWrite(RCLK_Pin, LOW);
for (int i = numOfRegisterPins -1; i >= 0; i--) {
digitalWrite(SRCLK_Pin, LOW);
int val = registers[i];
digitalWrite(SER_Pin, val);
digitalWrite(SRCLK_Pin, HIGH);
}
digitalWrite(RCLK_Pin, HIGH);
}
//set an individual pin high or low
void setRegisterPin (int index, int value) {
registers[index] = value;
}
void c_on() {
Serial.println("on");
setRegisterPin(13,LOW);
writeRegisters();
delay(50);
}
void c_off() {
Serial.println("off");
setRegisterPin(13,HIGH);
writeRegisters();
delay(50);
}
void loop() {
c_on();
delay(1000);
c_off();
delay(1000);
}
Is there any special thing to do for using esp32?
Thank you very much