Advertisement
kubbur

Untitled

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