evenjc

Untitled

Sep 23rd, 2020 (edited)
1,346
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SerialCommand.h>
  2.  
  3. #define arduinoLED 13   // Arduino LED on board
  4.  
  5. SerialCommand sCmd;     // The demo SerialCommand object
  6.  
  7. void setup() {
  8.  
  9.   Serial.begin(9600);
  10.  
  11.   // Setup callbacks for SerialCommand commands
  12.   sCmd.addCommand("ON",    LED_on);          // Turns LED on
  13.   sCmd.addCommand("OFF",   LED_off);         // Turns LED off
  14.  
  15. }
  16.  
  17. void loop() {
  18.   sCmd.readSerial();     // We don't do much, just process serial commands
  19. }
  20.  
  21.  
  22. void LED_on() {
  23.   Serial.println("LED on");
  24.   digitalWrite(arduinoLED, HIGH);
  25. }
  26.  
  27. void LED_off() {
  28.   Serial.println("LED off");
  29.   digitalWrite(arduinoLED, LOW);
  30. }
RAW Paste Data