Created
March 12, 2018 11:08
-
-
Save mabbotts9797/a767aa5e1e45eba117abd6ba0bd2006c to your computer and use it in GitHub Desktop.
This file contains 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
int LED_PIN = 9; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(LED_PIN, OUTPUT); | |
digitalWrite(LED_PIN, HIGH); | |
Serial.begin(9600); | |
Serial.println("* * * * * * * * * *"); | |
Serial.println("* LED I/O *"); | |
Serial.println("* Program *"); | |
Serial.println("* MA 2018 *"); | |
Serial.println("* * * * * * * * * * \n"); | |
Serial.println("(f)lash, (+) on, or (-) off \n"); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
char reading = Serial.read(); | |
if (reading == '-') | |
{ | |
Serial.println("LED off. \n"); | |
digitalWrite(LED_PIN, LOW); | |
} | |
if (reading == '+') | |
{ | |
Serial.println("LED on. \n"); | |
digitalWrite(LED_PIN, HIGH); | |
} | |
if (reading == 'f') | |
{ | |
Serial.println("LED flash. \n"); | |
flash(); | |
} | |
} | |
void flash() | |
{ | |
for (int i = 0; i <= 5; i++) | |
{ | |
digitalWrite(LED_PIN, HIGH); | |
delay(500); | |
digitalWrite(LED_PIN, LOW); | |
delay(500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment