[flv:servo_02.flv servo_02.jpg 500 375]
A servo controlled by a photo-resistor. I know, not that interesting, but I’m working on that…
Arduino / Wiring
//The code uses Michal Rinott's 'Knob' code. I just swapped resistors.
//connect the servo
//yellow is control - connect to pin 9 pwm
//red is power
//black is gnd
#include
Servo myServo;
int potPin = 0;
int val;
void setup (){
pinMode (potPin, INPUT);
myServo.attach (9);
Serial.begin (9600);
}
void loop (){
val = analogRead (potPin);
val = map (val, 0,1023,0,179); // convert to values in the 180 range
myServo.write (val);
delay (100);
Serial.println (val);
}
Tags: arduino