← Previous Invention

The Wacky Word Wizard

Next Invention →

Random Morse Code Messages

Light-Controlled Synth

In this invention, you'll use a light sensor to control the tone of the buzzer. If you move your hand closer to the sensor then the pitch will get lower, but it you take it away, it will get higher.

The Kit

The Amazing Annoyatron

Build this invention, and many more, with The Amazing Annoyatron!

What you’ll need

Brain Board


Light Dependant Resistor

Light Sensor


10k Resistor

Step 1

Let’s build this!

This is the positive leg of the buzzer. It will have a ‘+’ sign on top of it and will also be longer than the other leg.
Don’t forget to plug the board into your computer with the included USB cable.
For this to work, you’ll need to plug a leg from both the light sensor and the resistor into PIN A0.

To connect your buzzer, slide its pins into the board as shown – the positive leg should go in PIN 11 and the negative leg should go in GND.

For both the LDR and the resistor, it doesn’t really matter which way you connect either of them. Slide one of the light sensor’s pins into the 5V pin on the board and the other into A0. Connect the resistor between GND and AO again.

Step 2

Code some chaos!

Don’t forget to select your port, like ususal

Copy and paste the sample code

int LDR = A0;
int buzzer = 11;
int maxLight = 200;
int minLight = 0;
int light = 0;

void setup() {
    while(millis() < 5000) { light = analogRead(LDR); if(light > maxLight) maxLight = light;
      if(light < minLight) minLight = light;

void loop() {
  light = analogRead(LDR);

  int pitch = map(light,minLight,maxLight,50,4000);

  tone(buzzer, pitch, 10);