I've got an Arduino Uno.
I was building a simple circuit with only one switch and it doesn't seem to work (I followed the Arduino project book from the Arduino starter kit).
Then I try again to move the switch and then it works (but I don't understand why).
So I tried to understand where the error is and I try to read digital input from the simple circuit with only one LED :
And this is my code :
int SWITCH = 13;
void setup() {
Serial.begin(9600);
pinMode(SWITCH, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
int val;
val = digitalRead(SWITCH);
if(val == HIGH) {
Serial.println("OKAY");
}
}
I expect to see on the Serial Monitor "OKAY OKAY" and so on... but nothing appears on the Serial monitor.
Then I try to change the condition :
if(val == LOW)
And now I see "OKAY OKAY" and so on...
I think that there is something wrong with this Arduino... Can someone tell me something about what is happening? Am I stupid or there is really something wrong with this?