Advertisement
Guest User

Untitled

a guest
May 27th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #include <Servo.h>
  2. Servo motor1;
  3. Servo motor2;
  4. char readString;
  5. void setup()
  6. {
  7. Serial.begin( 9600);
  8. Serial.print("Code is spinoff by Baraq, original code by Jai Sawnhey");
  9. Serial.print(" ");
  10. Serial.print("Please say life if you see this");
  11. motor1.attach(7);
  12. motor2.attach(8);
  13.  
  14. }
  15. void loop()
  16. {
  17. while ( Serial.available() )
  18. { // While there is data in the buffer
  19. delay( 3 );
  20. char c = Serial.read();
  21. readString = c;
  22. }
  23.  
  24.  
  25. Serial.println( readString );
  26. //right
  27. /* if ( readString == "p" )
  28. {
  29. motor1.attach(7);
  30. motor1.write(99);
  31. }
  32. if ( readString == "s" )
  33. {
  34. motor1.attach(7);
  35. motor1.write(105);
  36. }
  37. if ( readString == "r" )
  38. {
  39. motor1.detach();
  40. //motor1.write(100);
  41. }
  42. readString="";
  43. }
  44. }
  45.  
  46. */
  47. /*
  48. if ( readString == "l2" )
  49. {
  50. motor2.write(80);
  51. }
  52. if ( readString == "r2" )
  53. {
  54. motor2.write(100);
  55. }
  56. if ( readString == "s2" )
  57. {
  58. motor2.write(90);
  59. }
  60. if ( readString == "l")
  61. {
  62. motor1.write(80);
  63. }
  64. if ( readString == "l")
  65. {
  66. motor1.write(100);
  67. }
  68. if ( readString == "s")
  69. {
  70. motor1.write(90);
  71. }
  72. }
  73. }
  74. */
  75. //motor 2 left
  76. //motor 1 right
  77. if ( readString == "s")
  78. {
  79. motor1.write(90);
  80. motor2.write(90);
  81. serial.println("Stop")
  82. }
  83. if ( readString == "l")
  84. {
  85. motor1.write(110);
  86. motor2.write(100);
  87. serial.println("")
  88. }
  89. if ( readString == "r")
  90. {
  91. motor2.write(110);
  92. motor1.write(90);
  93. }
  94. if ( readString == "f")
  95. {
  96. motor1.write(0);
  97. motor2.write(180);
  98. }
  99. if ( readString == "b")
  100. {
  101. motor1.write(120);
  102. motor2.write(60);
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement