For this week lab we had to create an input output coincidence device. I decided to create a DJ scratch device. This consisted of a photocell and potentiometer. The record could be spun to “scratch” the sounds from the speaker. This was done by spinning the broken record and changing the resistivity of the photocell beneath the record. The potentiometer holds the record and also acts as the volume control.
Components
1- Arduino Uno
1- Breadboard
1- 10k ohm Resistor
1 - Photocell
1- USB Cable
1- Potentiometer
1 - Piezoelectric Speaker
1 – Broken Record
Code:
int sensor = 0;
int speakerOut = 11; /* This makes a standard old PC speaker connector fit nicely over the pins.
void setup() {
Serial.begin(9600);
pinMode(speakerOut, OUTPUT);
pinMode(sensor, INPUT);
digitalWrite(speakerOut, LOW);
}
void loop() {
int val = analogRead(0); // read the value from the sensor, 0-1023
if (val < 500)
{
tone(speakerOut, 440, 100);
}
else
{
digitalWrite(speakerOut, LOW);
}
delay(20);
}
- Login to post comments