Pages: [1]   Go Down
Author Topic: Digital Input Problem  (Read 452 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  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.

Code:
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



Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know about DI3 but DI0 and DI1 are the serial I/O pins and will conflict with your use of Serial.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know about DI3 but DI0 and DI1 are the serial I/O pins and will conflict with your use of Serial.

  I understand this "could" be an issue however it transmits great when I transition DI0 to ground and it use to do well when I set DI1 to ground as well.  Something has changed and I suspect it's the same thing as that went wrong when DI3 quit working. 
  I find it hard to believe I'm blowing this pin on the chip, but If I am I wish I knew how so I could prevent it.
  Any ideas?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I am seeing a similar problem on my freetronics eleven. I configured pins 2 and 3 as digital inputs with an internal pullup. The pins where then connected to a switch that could ground them out.

For some reason it worked originally and then stopped. I now find that all pins on that port read digital inputs as low. Interestingly they still work as output pins though.

Other pins on different ports still work.

I have no solution, just wanted to say that I am facing a similar problem.
Logged

Pages: [1]   Go Up
Jump to: