Go Down

Topic: digitalWrite() command inverts? (Read 378 times) previous topic - next topic

thespiesman

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: [Select]
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.

thespiesman

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.

PaulS

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.

Go Up