Advertisement
kubbur

Untitled

Nov 15th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. // ssh root@ yourYunsName.local 'telnet localhost 6571'
  2.  
  3.  
  4.  
  5. #include <Console.h>
  6. #include <Servo.h>
  7.  
  8. const int ledPin = 13; // the pin that the LED is attached to
  9. char ib; // a variable to read incoming Console data into
  10. Servo servo1;
  11.  
  12. void setup()
  13.  
  14.  
  15. {
  16. servo1.attach(6); // Attach servo to pin 7
  17. Bridge.begin(); // Initialize Bridge
  18. Console.begin(); // Initialize Console
  19. pinMode(3, OUTPUT); // tone
  20. // Wait for the Console port to connect
  21. while(!Console);
  22.  
  23. Console.println("READY");
  24. tone (3, 800, 200);
  25. delay (200);
  26.  
  27.  
  28. // initialize the LED pin as an output:
  29. pinMode(ledPin, OUTPUT);
  30. }
  31.  
  32. void loop() {
  33. // see if there's incoming Console data:
  34. if (Console.available() > 0) {
  35. // read the oldest byte in the Console buffer:
  36. ib = Console.read();
  37. if (ib == 'S') // if Byte is S
  38. {
  39. uint8_t b1 = Console.read (); //read next 3 numbers that come after S
  40. uint8_t b2 = Console.read ();
  41. uint8_t b3 = Console.read ();
  42. servo1.write((b1 - '0')*100 + (b2 - '0')*10 + b3 - '0');
  43. }
  44. // if it's a capital H (ASCII 72), turn on the LED:
  45. if (ib == 'H') {
  46. digitalWrite(ledPin, HIGH);
  47. }
  48. // if it's an L (ASCII 76) turn off the LED:
  49. if (ib == 'L') {
  50. digitalWrite(ledPin, LOW);
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement