Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myServo;
- int state=2;
- void setup() {
- myServo.attach(9);
- pinMode(10,OUTPUT);
- Serial.begin(9600);
- }
- void loop() {
- if(Serial.available() > 0){ // Checks whether data is coming from the serial port
- state = Serial.read(); // Reads the data from the serial port
- }
- if(state==0){
- digitalWrite(10,HIGH);
- myServo.write(40);
- }
- if(state==1){
- digitalWrite(10,LOW);
- myServo.write(10);
- }
- Serial.println(state);
- }
Add Comment
Please, Sign In to add comment