Description:
I made a cardboard figure with a circular cutout in its stomach that spins (using a DC motor) when a hand is close to it (using a photocell). One of the difficulties that arose was finding the lowest possible range of speeds for the motor.
Materials:
1- Breadboard
1- Arduino Uno
1 1K Ohm resistor
1 10K Ohm Resistor
1 DC motor
1 2 x 1.5V AA battery pack
1 Zener Diode
1 Transistor
1 Photocell
Cardboard
Code:
/*
* Anxious doll
* One photocell fades the motor.
*/
int pcPin = A0;
int motorPin = 9;
int val = 0;
void setup() {
pinMode(pcPin, INPUT);
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
val = 120 - analogRead(pcPin)/4;
Serial.println(val);
if(val > 0) {
if (val > 10) {
analogWrite(motorPin, 40);
} else {
analogWrite(motorPin, val + 30);
}
}
}
Images:
http://i40.tinypic.com/5cg9qg.jpg
- Login to post comments