|
|
|
#define RED_PIN 3 // no need for equal. Don't use a semi-colon |
|
#define BLUE_PIN 6 |
|
#define GREEN_PIN 5 |
|
#define RED_BUTTON 7 |
|
#define GREEN_BUTTON 8 |
|
#define BLUE_BUTTON 9 |
|
int redButtonState = 0; |
|
int greenButtonState = 0; |
|
int blueButtonState = 0; |
|
|
|
// the setup function runs once when you press reset or power the board |
|
void setup() { |
|
// initialize digital pin LED_BUILTIN as an output. |
|
pinMode(RED_PIN, OUTPUT); |
|
pinMode(BLUE_PIN, OUTPUT); |
|
pinMode(GREEN_PIN, OUTPUT); |
|
|
|
pinMode(RED_BUTTON, INPUT); |
|
pinMode(GREEN_BUTTON, INPUT); |
|
pinMode(BLUE_BUTTON, INPUT); |
|
Serial.begin(9600); |
|
} |
|
|
|
// the loop function runs over and over again forever |
|
void loop() { |
|
redButtonState = digitalRead(RED_BUTTON); |
|
if (redButtonState == HIGH) { |
|
digitalWrite(RED_PIN, HIGH); |
|
Serial.println("RED HIGH"); |
|
} else { |
|
digitalWrite(RED_PIN, LOW); |
|
Serial.println("RED LOW"); |
|
} |
|
|
|
greenButtonState = digitalRead(GREEN_BUTTON); |
|
if (greenButtonState == HIGH) { |
|
digitalWrite(GREEN_PIN, HIGH); |
|
Serial.println("GREEN HIGH"); |
|
} else { |
|
digitalWrite(GREEN_PIN, LOW); |
|
Serial.println("GREEN LOW"); |
|
} |
|
|
|
blueButtonState = digitalRead(BLUE_BUTTON); |
|
if (blueButtonState == HIGH) { |
|
digitalWrite(BLUE_PIN, HIGH); |
|
Serial.println("BLUE HIGH"); |
|
} else { |
|
digitalWrite(BLUE_PIN, LOW); |
|
Serial.println("BLUE LOW"); |
|
} |
|
} |