Created
June 19, 2018 01:50
-
-
Save gallaugher/380ed21397f229161ba5de06c9b8a61a to your computer and use it in GitHub Desktop.
Gallaugher LBD 7 Mini Project 1 - Just the Red Light Working for Button Press
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 | |
| int buttonState = 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); | |
| Serial.begin(9600); | |
| } | |
| // the loop function runs over and over again forever | |
| void loop() { | |
| buttonState = digitalRead(RED_BUTTON); | |
| if (buttonState == HIGH) { | |
| digitalWrite(RED_PIN, HIGH); | |
| } else { | |
| digitalWrite(RED_PIN, LOW); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment