Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #From BeagleBone Cookbook!
- char inChar = 0;
- int red = 0;
- int green = 0;
- void setup()
- {
- pinMode(RED_LED, OUTPUT);
- pinMode(GREEN_LED, OUTPUT);
- Serial.begin(9600);
- Serial.print("Command (r,g): ");
- digitalWrite(GREEN_LED, green);
- digitalWrite(RED_LED, red);
- }
- void loop()
- {
- if(Serial.available() > 0) {
- inChar = Serial.read();
- switch(inChar) {
- case 'g':
- green = ~green;
- digitalWrite(GREEN_LED, green);
- Serial.println("Green");
- break;
- case 'r':
- red = ~red;
- digitalWrite(RED_LED, red);
- Serial.println("Red");
- break;
- }
- Serial.print("Command (r, g): ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement