Skip to content

Instantly share code, notes, and snippets.

@mabbotts9797
Created March 12, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mabbotts9797/a767aa5e1e45eba117abd6ba0bd2006c to your computer and use it in GitHub Desktop.
Save mabbotts9797/a767aa5e1e45eba117abd6ba0bd2006c to your computer and use it in GitHub Desktop.
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