You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
599 B

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. int recv = 0;
  2. // 0 FORWARD
  3. // 1 BACKWARD
  4. // 2 LEFT
  5. // 3 RIGHT
  6. void setup() {
  7. Serial.begin(115200); //initial the Serial
  8. }
  9. void loop() {
  10. if (Serial.available()) {
  11. switch (Serial.read())
  12. {
  13. case 0:
  14. Serial.println("MOVING FORWARD");
  15. break;
  16. case 1:
  17. Serial.println("MOVING BACKWARD");
  18. break;
  19. case 2:
  20. Serial.println("MOVING LEFT");
  21. break;
  22. case 3:
  23. Serial.println("MOVING RIGHT");
  24. break;
  25. default:
  26. Serial.println("INVALID INSTRUCTION");
  27. }
  28. }
  29. }