My first steps were getting the servo and light-dependent resistor to work together.
My code was fairly simple:
#include <Servo.h>
Servo s;
void setup() {
//pinMode(8,OUTPUT);
pinMode(A0, INPUT);
Serial.begin(9600);
s.attach(8);
}
void loop() {
float l = analogRead(A0);
Serial.print(l);
Serial.print(" ");
int v = map(l,0,1024,0,179);
s.write(v);
//delay(120);
Serial.println(v);
}
I initially tried to include a delay to make the servo turn more slowly. All this did was make the servo react to the light turning on, but then once the light was turned back off, the servo did nothing. The light resistor stopped outputting any information once it hit 1023.
Demonstration
Sunday, October 16, 2016
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment