Advertisement
Guest User

Untitled

a guest
May 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <SoftwareSerial.h> //Software Serial Port
  2. #define RxD 11
  3. #define TxD 12
  4. #include <Servo.h>
  5.  
  6. #define DEBUG_ENABLED 1
  7. Servo Ser;
  8. SoftwareSerial BT(RxD,TxD);
  9.  
  10. void setup()
  11. {
  12. pinMode(13, OUTPUT);
  13. Ser.attach(9);
  14. Serial.begin(9600);
  15. BT.begin(9600);
  16. }
  17.  
  18. void loop()
  19. {
  20. while (BT.available() == 0); // wait for character to arrive
  21. char c = BT.read();
  22.  
  23. if(c =='1') {
  24. digitalWrite(13, HIGH);
  25. Serial.println("ca marche");
  26. BT.println("salut");
  27. for (int position = 60; position <= 180; position++)
  28. {
  29. Ser.write(position);
  30. delay(15);
  31. }
  32.  
  33. }
  34. if(c == '0'){
  35. digitalWrite(13, LOW);
  36. Serial.println("ca marche plus");
  37. BT.println("ca va");
  38. for (int position = 180; position >= 0; position--) {
  39. Ser.write(position);
  40. delay(15);
  41. }
  42. }
  43. delay(500);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement