Arduino Lesson 10
Light Control Sound
Parts requried
Photovaristor x 1
Buzzer x 1
Jumper wires x 1 Bundle
Connect-it-up
One outlet of photovaristor accese to digital interface #6, the other
outlet access to anode of the buzzer, cathode of buzzer access to GND.
Experiment Theory
This program applies the previous lessons about reading the analog voltage value,
similar to buzzer experiment. When there is no light, sound is weak. When there is
light, the resistance reduced, so at the ends of the voltage will increase, buzzer make
stronger sounds. The stronger the light, the smaller the resistance, buzzer rang
harder.
void setup()
{
pinMode(6,OUTPUT);
}
void loop()
{
while(1)
{
char i,j;
while(1)
{
for(i=0;i<80;i++) //make sound by 1 frenquency
{
digitalWrite(6,HIGH);
delay(1);
digitalWrite(6,LOW);
delay(1);
}
for(i=0;i<100;i++) //make sound by other frequency
{
digitalWrite(6,HIGH);
delay(2);
digitalWrite(6,LOW);
delay(2);
}
}
}
}
Download the program to Arduino, use the flash light spot on the
photovaristor and you can hear the sound from buzzer.