Arduino Uno + Photocell + 1 kΩ Resistor + Small Servo
BRIGHT!
DARK...
Okay this is basically a superbeginner mashup of these two basic tutorials: Adafruit's Making Sounds (Lesson 10) + Adafruit's Servo Motors (lesson 14). Well I guess I gotta start somewhere so don't laugh at the simpleness of this. I'm just writing it out here because I will probably forget it all if I don't write it down properly, and god knows actual hardware is an undiscovered country for me.
#includeint servoPin = 9; Servo servo; int angle = 0; // servo position in degrees int photocellPin = 0; void setup() { servo.attach(servoPin); //Serial.begin(9600); } void loop() { int reading = analogRead(photocellPin); int newAngle = reading/3 - 100; //Serial.print(newAngle); //Serial.print("\n"); servo.write(newAngle); delay(60); }
Fritzing
I made a sketch of the above with Fritzing. Fritzing is a useful tool for designers and programmers to design and document their prototypes for pcb boards, arduino-based and other electronics projects. Drag and drop and pull...
Thank you soo much! :D
ReplyDelete