Created
July 4, 2016 23:15
-
-
Save TURBULENTE/db958e8de1dca393c6a2e01cceb95430 to your computer and use it in GitHub Desktop.
Code test for making a servo move with a light resistor using Arduino UNO.
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
#include <Servo.h> | |
Servo myservo; | |
int motor = 9; // LED connected to digital pin 9 | |
int val; | |
void setup() { | |
// nothing happens in setup | |
myservo.attach(motor); | |
Serial.begin(9600); | |
} | |
void loop() { | |
//sensor | |
val = analogRead(A5); | |
val = map(val, 0, 1023, 0, 180); | |
if (val>160){ | |
}else{ | |
myservo.write(val); | |
delay(15); | |
Serial.println(val); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment