Created
October 5, 2012 15:25
-
-
Save mitsuruog/3840478 to your computer and use it in GitHub Desktop.
Arduino Serial connection
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
#define LED_PIN 13 | |
void setup(){ | |
pinMode(LED_PIN, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop(){ | |
int input; | |
input = Serial.read(); | |
if(input == -1){ | |
return; | |
} | |
switch(input){ | |
case 'o': | |
Serial.print("LED ON\n"); | |
digitalWrite(LED_PIN, HIGH); | |
break; | |
case 'p': | |
Serial.print("LED OFF\n"); | |
digitalWrite(LED_PIN, LOW); | |
break; | |
case 'b': | |
Serial.print("LED Blinking\n"); | |
brink10(); | |
break; | |
} | |
Serial.print("READY\n"); | |
} | |
void brink10(){ | |
for(int i=0; i<10; i++){ | |
digitalWrite(LED_PIN, HIGH); | |
delay(200); | |
digitalWrite(LED_PIN, LOW); | |
delay(200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment