Advertisement
silver2row

INI File from the BeagleBone Cookbook!

Apr 4th, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #From BeagleBone Cookbook!
  2.  
  3. char inChar = 0;
  4. int red = 0;
  5. int green = 0;
  6.  
  7. void setup()
  8. {
  9.    pinMode(RED_LED, OUTPUT);
  10.    pinMode(GREEN_LED, OUTPUT);
  11.    
  12.    Serial.begin(9600);
  13.    Serial.print("Command (r,g): ");
  14.    
  15.    digitalWrite(GREEN_LED, green);
  16.    digitalWrite(RED_LED, red);
  17. }
  18.  
  19. void loop()
  20. {
  21.    if(Serial.available() > 0) {
  22.       inChar = Serial.read();
  23.       switch(inChar) {
  24.          case 'g':
  25.             green = ~green;
  26.             digitalWrite(GREEN_LED, green);
  27.             Serial.println("Green");
  28.             break;
  29.          case 'r':
  30.             red = ~red;
  31.             digitalWrite(RED_LED, red);
  32.             Serial.println("Red");
  33.             break;
  34.          }
  35.          Serial.print("Command (r, g): ");
  36.    }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement