Pages: [1]   Go Down
Author Topic: digitalWrite() command inverts?  (Read 304 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I'm just running this simple test to make sure that my digital outputs are doing what they are supposed to because I noticed some strange behaviour pop up as I was working on a project:

Code:
void setup()  {
  pinMode(5, OUTPUT);
}

void loop()  {
  digitalWrite(5, HIGH);
}

The strange part about this is that while pin 5 should read in at 5V it is reading at 0V, and if I replace HIGH with LOW I get 5V. I'm also getting this independent of which pin I select via pinMode(). Did my Arduino board mess up in a big way, or is there something wrong on my compiler's end? Is there a way to check either? I use an Arduino Duemilanova if that is helpful.
Logged

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

Disregard this post. I figured out the issue and it was a simple wiring problem that somehow confused GND as +5V and +5V as GND. Protip: check to make sure that the wires are going where you think they are going before you assume that the arduino board is interpreting programs incorrectly.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46026
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Protip: check to make sure that the wires are going where you think they are going before you assume that the arduino board is interpreting programs incorrectly.   
Excellent advice. I'm willing to bet that when you make that mistake again, it will take you far less time to find it.
Logged

Pages: [1]   Go Up
Jump to: