Project 5: Play Different Tones as Light Intensity Changes (tonePitchFollower)

Created on: 2 August 2012
Updated on: 17 January 2023

Tutorial 10 – Pages

In this Arduino tutorial for beginners a tone is played on a loudspeaker that changes pitch as the light intensity levels on an LDR change. Moving your hand around the LDR causes the light intensity to change. The value from the LDR is read on the Arduino analog pin A0. This value is displayed in the Arduino serial monitor window.

Parts Needed

An Arduino Uno, USB cable, breadboard and wire links are needed for the Arduino tone pitch follower project, as well as the following electronics components.

  • 1 × LDR (Light Dependent Resistor)
  • 1 × 8 ohm loudspeaker
  • 1 × 4k7 resistor
  • 1 × 100 ohm resistor

Project 5 Video: Arduino Audio Tones Change as Light Intensity Changes

The following video shows that moving one's hand around the LDR causes the light levels on the LDR to change. This in turn causes the tone on the loudspeaker to change.

Arduino Website Page

The tonePitchFollower Arduino web page shows the circuit diagram and breadboard layout for this project.

In the Arduino IDE

Find the sketch for this project by selecting File → Examples → 2.Digital → tonePitchFollower from the top menu of the Arduino IDE.

Building the Circuit

The circuit diagram and breadboard connections can be found on the tonePitchFollower page on the Arduino website.

To build the circuit, use a breadboard to connect a 100Ω resistor to pin 8 of the Arduino. Now connect one of the loudspeaker leads to the free end of the 100Ω resistor. Connect the other loudspeaker lead to an Arduino GND pin.

Connect one of the LDR pins to the Arduino 5V pin, and the other to the Arduino A0 pin. Finally connect a 4k7 resistor from the A0 pin to an Arduino GND pin.

Programming and Operating the Circuit

Select File → Examples → 2.Digital → tonePitchFollower in the Arduino IDE to open the sketch for this project. Upload the sketch to the Arduino board.

If you would like to see the values that are being read on analog pin A0 of the Arduino, then open the serial monitor from the Arduino IDE. Move your hand around the LDR and hear the pitch played on the loudspeaker change.