Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h> //Software Serial Port
- #define RxD 11
- #define TxD 12
- #include <Servo.h>
- #define DEBUG_ENABLED 1
- Servo Ser;
- SoftwareSerial BT(RxD,TxD);
- void setup()
- {
- pinMode(13, OUTPUT);
- Ser.attach(9);
- Serial.begin(9600);
- BT.begin(9600);
- }
- void loop()
- {
- while (BT.available() == 0); // wait for character to arrive
- char c = BT.read();
- if(c =='1') {
- digitalWrite(13, HIGH);
- Serial.println("ca marche");
- BT.println("salut");
- for (int position = 60; position <= 180; position++)
- {
- Ser.write(position);
- delay(15);
- }
- }
- if(c == '0'){
- digitalWrite(13, LOW);
- Serial.println("ca marche plus");
- BT.println("ca va");
- for (int position = 180; position >= 0; position--) {
- Ser.write(position);
- delay(15);
- }
- }
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement