Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #include <Servo.h>
- Servo myservo;
- int rxPin = 7;
- int txPin = 8;
- SoftwareSerial bluetooth(rxPin, txPin);
- String message; //string that stores the incoming message
- void setup()
- {
- myservo.attach(11);
- Serial.begin(9600); //set baud rate
- bluetooth.begin(9600); //set baud rate
- }
- void loop()
- {
- while(bluetooth.available()){
- message+=char(bluetooth.read());
- }
- if(!bluetooth.available())
- {
- if(message!=""){
- int x = message.toInt();
- Serial.println(message); //show the data
- Serial.println(x); //show the data
- if (x<180){
- myservo.write(x);
- message=""; //clear the data
- }
- }
- }
- delay(50); //delay
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement