Description
For the homework assignment following this lab, I used the DC motor to create a rotational motion resulting in an optical illusion. The optical illusion uses a printed pattern on a circular cardboard piece. When the pattern is rotated at high speeds, the pattern elements begin to blend together. The illusion is also based on the limits of human perception, in whcih under-sampling of the complete optical signal takes place and the human brain attempts to reconstruct the image without having sampled the entire optical signal. At higher rotational speeds of the motor, aliasing of the optical information streaming into the viewer occurs and the pattern can take on interesting characteristics. For example, the pattern can begin to appear as though it is spinning in the opposite direction that it really is or as if the speed of the rotating pattern is changing. In addition, I added an element of sound using the piezo speaker that correspondingly increases in pitch when the rotational speed of the motor increases. The use of sound enhances the experience because it can provide an audible point of reference for the viewers when it might be difficult to identify how fast the shaft of the motor is actually rotating. The noise can become annoying, however, so I added a resistor to decrease the volume of the speaker.
Components
1- Arduino Uno Microcontroller
1- Breadboard
1- 1KΩ Resistor
1- 10KΩ Resistor
1- USB Cable
1- Apple Laptop Computer (Mac OSX)
1 - Piezoelectric Speaker
1 - DC Motor
1 - 1N4004 Diode
1 - TIP120 Transistor
1 - 3V External Power Supply
1 - Potentiometer
Code
/* Stuart Altman
* modified code from class to include speaker output
* one pot fades one motor
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* http://www.arduino.cc/en/Tutorial/AnalogInput
* Modified again by dave
*/
int potPin = 0; // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int val = 0; // variable to store the value coming from the sensor
int speaker = 8;
void setup() {
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
int sensorReading = analogRead(A0);
pinMode(speaker, OUTPUT);
int thisPitch = map(sensorReading, 0, 1023, 120, 1500);
// play the pitch:
tone(speaker, thisPitch, 10);
delay(1); // delay in between reads for stability
}
Images
- Login to post comments