Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- int servoPin = 3;
- int button = 2;
- Servo Servo1;
- void setup() {
- Serial.begin(9600);
- pinMode(button, INPUT_PULLUP);
- Servo1.attach(servoPin);
- }
- void loop() {
- int sensorVal = digitalRead(2);
- Serial.println(sensorVal);
- if (sensorVal == HIGH) {
- digitalWrite(13, LOW);
- Servo1.write(0);
- } else {
- digitalWrite(13, HIGH);
- Servo1.write(180);
- }
- delay(1); // delay between reads
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement