Guest User

Untitled

a guest
Sep 30th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. const int AIA = 3;
  2. const int AIB = 4;
  3. const int BIA = 5;
  4. const int BIB = 6;
  5. byte speed = 255;
  6. int cnt = 0;
  7. byte bbb;
  8. String myString;
  9. void forward()
  10. {
  11. analogWrite(AIA, 0);
  12. analogWrite(AIB, speed);
  13. analogWrite(BIA, 0);
  14. analogWrite(BIB, speed);
  15. }
  16. void backward()
  17. {
  18. analogWrite(AIA, speed);
  19. analogWrite(AIB, 0);
  20. analogWrite(BIA, speed);
  21. analogWrite(BIB, 0);
  22. }
  23. void setup() {
  24. pinMode(AIA, OUTPUT);
  25. pinMode(AIB, OUTPUT);
  26. pinMode(BIA, OUTPUT);
  27. pinMode(BIB, OUTPUT);
  28. Serial.begin(9600);
  29. }
  30. void loop() {
  31. while (Serial.available())
  32. {
  33. char myChar = (char)Serial.read();//
  34. myString += myChar;
  35. delay(05);
  36. }
  37. if (!myString.equals(""))// {
  38. Serial.println("Input Value : " + myString);
  39. int ccc = myString.toInt();
  40. speed = (byte)ccc;
  41. myString = "";
  42. }
  43. forward();
  44. delay(2000);
  45. backward();
  46. delay(2000);
  47. }
Add Comment
Please, Sign In to add comment