Guest User

Untitled

a guest
Nov 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. SoftwareSerial BTSerial(0, 1); // RX | TX
  3. int backFront = 3;
  4. int backBack = 2;
  5. int frontLeft = 5;
  6. int frontRight = 6;
  7.  
  8. void setup(){
  9. pinMode(backFront, OUTPUT);
  10. pinMode(backBack, OUTPUT);
  11. pinMode(frontLeft, OUTPUT);
  12. pinMode(frontRight, OUTPUT);
  13. Serial.begin(9600);
  14. BTSerial.begin(38400);
  15. }
  16.  
  17. void loop(){
  18. char input;
  19.  
  20.  
  21. if (Serial.available()>0){
  22. input = Serial.read();
  23. Serial.write(input);
  24.  
  25. }
  26.  
  27. if (input == 'u' || input == 'U'){
  28. digitalWrite(backFront, HIGH);
  29. }
  30. if (input == 'd' || input == 'D'){
  31. digitalWrite(backBack, HIGH);
  32. }
  33. if (input == 'l' || input == 'L'){
  34. digitalWrite(frontLeft, HIGH);
  35. }
  36. if (input == 'r' || input == 'R'){
  37. digitalWrite(frontRight, HIGH);
  38. }
  39. delay(300);
  40.  
  41. digitalWrite(backFront, LOW);
  42. digitalWrite(backBack, LOW);
  43. digitalWrite(frontLeft, LOW);
  44. digitalWrite(frontRight, LOW);
  45. }
Add Comment
Please, Sign In to add comment