Skip to content

Instantly share code, notes, and snippets.

@mitsuruog
Created October 5, 2012 15:25
Show Gist options
  • Save mitsuruog/3840478 to your computer and use it in GitHub Desktop.
Save mitsuruog/3840478 to your computer and use it in GitHub Desktop.
Arduino Serial connection
#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