For this lab, I wanted to create an optical illusion through the movement of the DC motor. I stuck a round shaped piece of stiff paper and tried out several designs. What I wanted was an outward moving spiral and I think my design is right because I can kind of see it when the motor is turning off but otherwise, the motor spins too fast for the effect to be visible to the naked eye. I settled with a design which too demonstrates how perception works and what we see may not be what is.
Components
- Arduino Uno
- breadboard
- 1 DC motor
- 1 Transistor
- 1 Diode
- 1 resistors (one 1KΩ)
- 1 potentiometer
- battery pack
- two AA batteries
- jumper wires
Arduino Code
/*
* one pot fades one motor and LED
*/
int potPin = A0; // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int val; // variable to store the value coming from the sensor
void setup() {
pinMode (potPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 – 1024
Serial.println(val);
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
}