I’m having problems with a program I wrote and in the troubleshooting process I’ve narrowed it down to a digital input issue. My initial program used several digital inputs (with the internal pull-up resister). I installed switches to switch the input to ground. Unfortunately one and then two of the inputs quit working. It did work in the past, but no longer.
I wrote a test program to verify, see below. DI1 and DI3 no longer operate correctly.
void setup() {
Serial.begin(9600);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
}
void loop(){
int DI0 = digitalRead(0);
int DI1 = digitalRead(1);
int DI2 = digitalRead(2);
int DI3 = digitalRead(3);
int DI4 = digitalRead(4);
int DI5 = digitalRead(5);
int DI6 = digitalRead(6);
int DI7 = digitalRead(7);
Serial.print("DI0 = ");
Serial.print(DI0);
Serial.print(", DI1 = ");
Serial.print(DI1);
Serial.print(", DI2 = ");
Serial.print(DI2);
Serial.print(", DI3 = ");
Serial.print(DI3);
Serial.print(", DI4 = ");
Serial.print(DI4);
Serial.print(", DI5 = ");
Serial.print(DI5);
Serial.print(", DI6 = ");
Serial.print(DI6);
Serial.print(", DI7 = ");
Serial.println(DI7);
}
Serial monitor results:
DI0 = 1, DI1 = 0, DI2 = 1, DI3 = 0, DI4 = 1, DI5 = 1, DI6 = 1, DI7 = 1
DI0 = 1, DI1 = 0, DI2 = 1, DI3 = 0, DI4 = 1, DI5 = 1, DI6 = 1, DI7 = 1
DI0 = 1, DI1 = 0, DI2 = 1, DI3 = 0, DI4 = 1, DI5 = 1, DI6 = 1, DI7 = 1
DI0 = 1, DI1 = 0, DI2 = 1, DI3 = 0, DI4 = 1, DI5 = 1, DI6 = 1, DI7 = 1
DI0 = 1, DI1 = 0, DI2 = 1, DI3 = 0, DI4 = 1, DI5 = 1, DI6 = 1, DI7 =à1
DI0 = 1, Dy1 ý 0, Dyþî?b"%Íîþ
DI1 and DI3 will always display 0. Grounding DI3 has no affect and when I ground DI1 I get the last line from above.
Any suggestions (short of a blown chip)? Thanks in advance for your help.
Brian