Created
April 8, 2020 14:05
-
-
Save EDISON-SCIENCE-CORNER/bdf3e2e83373815c1b18326104287394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//EDISON SCIENCE CORNER// | |
//EDISON SCIENCE CORNER// | |
//EDISON SCIENCE CORNER// | |
//EDISON SCIENCE CORNER// | |
//EDISON SCIENCE CORNER// | |
#include <Servo.h> | |
int switchPin = A0; | |
const int servoPin = 9; | |
Servo servo; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(switchPin,INPUT); | |
servo.attach(servoPin); | |
} | |
void loop() { | |
int X=analogRead(switchPin); | |
if (X<450){ | |
servo.write(30); | |
} | |
if(X>450){ | |
servo.write(90); | |
} | |
Serial.println(X); | |
delay(1);} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment