Hi,
I had a silly question.
I'm looking at this code:
// Example 02: Turn on LED while the button is pressed
//
// Copy and paste this example into an empty Arduino sketch
#define LED 13 // the pin for the LED
#define BUTTON 7 // the input pin where the
// pushbutton is connected
int val = 0; // val will be used to store the state
// of the input pin
void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}
void loop(){
val = digitalRead(BUTTON); // read input value and store it
// check whether the input is HIGH (button pressed)
if (val == HIGH) {
digitalWrite(LED, HIGH); // turn LED ON
} else {
digitalWrite(LED, LOW);
}
}
And I'm unclear on something....val = digitalRead(BUTTON);
My understanding is that reading the button will give you HIGH or LOW. But these aren't integers, they are strings.
So how can HIGH be assigned to a integer? Unless HIGH really = 1, and LOW = 0, and the Arduino compiler knows this and converts them behind the scences automatically?
I know it's a dumb question, but I just want to make sure I'm not crazy =)
Thanks!