Saturday, August 5, 2017

Light-Activated Sound

Light-Activated Sound

Now lets have fun with sound. Shining a light on the photocell will produce a sound ☺


Hookup for Light-Activated Sound


--------------------------- Copy Code Below
int sensorValue;

void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
sensorValue = analogRead(A0);
if (sensorValue > 500)

  //digitalWrite(13, LOW);
  tone(13,1000);
}
else
{
  //digitalWrite(13, HIGH);
  noTone(13); }
}

No comments:

Post a Comment