Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myservo;
- int a = 90;
- char val;
- void setup() {
- Serial.begin(9600); // Start serial communication at 9600 bps
- myservo.attach(3);
- myservo.write(a);
- }
- void loop() {
- while (Serial.available()) { // If data is available to read,
- val = Serial.read(); // read it and store it in val
- }
- if (val == 'H') {
- a = a - 1;
- if(a < 0 )a=0;
- myservo.write(a);
- } if(val == 'L'){
- a = a + 1;
- if(a > 180)a = 180;
- myservo.write(a);
- }
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement