|
I accidently plug 12 Volt to GND of DI sockets.
Even though, I did not plugged any wire on DI, I am getting the below output.
When I check it with Voltmeter, DIs is giving me 12V
Does that mean, I did burn the card? Or a code error?
code:
Code: #include "PCF8574.h"
//I2C INPUT
TwoWire I2C_0 = TwoWire(0);
PCF8574 pcf8574_I1(&I2C_0, 0x24, 4, 5);
PCF8574 pcf8574_I2(&I2C_0, 0x25, 4, 5);
PCF8574 pcf8574_I3(&I2C_0, 0x21, 4, 5);
PCF8574 pcf8574_I4(&I2C_0, 0x22, 4, 5);
//I2C RELAY
TwoWire I2C_1 = TwoWire(1);
PCF8574 pcf8574_R1(&I2C_1, 0x24, 15, 13);
PCF8574 pcf8574_R2(&I2C_1, 0x25, 15, 13);
PCF8574 pcf8574_R3(&I2C_1, 0x21, 15, 13);
PCF8574 pcf8574_R4(&I2C_1, 0x22, 15, 13);
void setup_input() {
for(int i=0;i<=7;i++){
pcf8574_I1.pinMode(i, INPUT);
pcf8574_I2.pinMode(i, INPUT);
pcf8574_I3.pinMode(i, INPUT);
pcf8574_I4.pinMode(i, INPUT);
}
pcf8574_I1.begin();
pcf8574_I2.begin();
pcf8574_I3.begin();
pcf8574_I4.begin();
}
void setup_output() {
for(int i=0;i<=7;i++)
{
pcf8574_R1.pinMode(i, OUTPUT);
pcf8574_R2.pinMode(i, OUTPUT);
pcf8574_R3.pinMode(i, OUTPUT);
pcf8574_R4.pinMode(i, OUTPUT);
}
pcf8574_R1.begin();
pcf8574_R2.begin();
pcf8574_R3.begin();
pcf8574_R4.begin();
for(int i=0;i<=7;i++) {
pcf8574_R1.digitalWrite(i, HIGH);
pcf8574_R2.digitalWrite(i, HIGH);
pcf8574_R3.digitalWrite(i, HIGH);
pcf8574_R4.digitalWrite(i, HIGH);
}
}
void setup_serial(){
Serial.begin(115200);
while (!Serial && (millis() < 3000));
}
void print_chip_arduino(){
Serial.print(F("\n\n----------------\n\n"));
Serial.print(F("ARDUINO_BOARD:"));
Serial.println(String(ARDUINO_BOARD));
}
unsigned long currentTime = millis();
void refreshCurrentTime(){
currentTime = millis();
}
void print_loopHeader(){
Serial.print(F("---------"));
Serial.print(F("t: "));
Serial.print(String(currentTime));
Serial.println(F(" ---------"));
}
void print_input(){
for(int i=0;i<=7;i++) {
bool input1 = pcf8574_I1.digitalRead(i);
bool input2 = pcf8574_I2.digitalRead(i);
bool input3 = pcf8574_I3.digitalRead(i);
bool input4 = pcf8574_I4.digitalRead(i);
Serial.print(F("i:"));
Serial.print(String(i));
Serial.print(F(" I1:"));
Serial.print(String(input1));
Serial.print(F(" I2:"));
Serial.print(String(input2));
Serial.print(F(" I3:"));
Serial.print(String(input3));
Serial.print(F(" I4:"));
Serial.println(String(input4));
}
}
void setup() {
setup_input();
setup_output();
setup_serial();
print_chip_arduino();
}
void loop() {
refreshCurrentTime();
print_loopHeader();
print_input();
delay(1000);
}
output:
Code: ---------t: 8096 ---------
i:0 I1:1 I2:1 I3:1 I4:1
i:1 I1:1 I2:1 I3:1 I4:1
i:2 I1:1 I2:1 I3:1 I4:1
i:3 I1:1 I2:1 I3:1 I4:1
i:4 I1:1 I2:1 I3:1 I4:1
i:5 I1:1 I2:1 I3:1 I4:1
i:6 I1:1 I2:1 I3:1 I4:1
i:7 I1:1 I2:1 I3:1 I4:1
|