Académique Documents
Professionnel Documents
Culture Documents
A. G. Turtulea (30312)
T. S. Baltaretu (30312)
E-mail: alexadra_turtulea@yahoo.com
teodorstelian98@yahoo.com
Abstract. This article presents the implementation of an Arduino Piano using LDR Sensors and
a Piezo Buzzer.
1. Introduction
These guidelines show how you should proceed for implementing an Arduino “piano”, using LDRs,
LEDs and a Piezo Buzzer.
A piezo buzzer is an audio signalling device which may be driven by an oscillating electronic circuit or
other audio signal source, driven with a piezoelectric audio amplifier. Sounds commonly used to indicate
that a button has been pressed are a click, a ring or a beep.
4. Implementation
We used :
Each LED is connected to GND and to a digital pin, as will be shown in the following code, using digital
2, 3, 4, 5, 6, 7 inputs.
Each LDR sensor is connected to an analogue input (A0 – A5). Since the Arduino UNO board has only 6
analogue inputs, we used only 6 LDR sensor, even though a piano keyboard should be composed of at
least 7 sound tones (DO, RE, MI, FA, SOL, LA, SI).
The Piezo Buzzer is connected to analogue input 13 and is programmed to action when a certain LDR
sensor’s output value (in the Serial Monitor) decreases below 300. The following frequencies were used:
Do = 262, Re = 294, Mi = 330 , Fa = 349 , Sol = 392 , La = 440.
5. Programming
//definitions of constants
const int ledPin[] = { 2, 3, 4, 5, 6, 7 };
int sensorValue = 0;
//void setup
void setup() {
Serial.begin(9600);
pinMode(i, OUTPUT); }
//loop fragments
void loop() {
sensorValue = analogRead(keyPins[analogs]);
Serial.println(sensorValue);
delay(200);
noTone(buzzerPin);
}
else if (sensorValue > 300)
digitalWrite(ledPin[led], LOW);
noTone(buzzerPin);
//after a sequence of algorithms implented in the same way, we added a small delay between the
reading for stability
delay(200);
The frequency is an unsigned integer and can take a value up to 65,535 – but if you are trying to make
tones for the human ear, then values between 2,000 and 5,000 are where our ears are most tuned.
6. Conclusions
In conclusion, this project was easy to implement but also, for us, a very interesting concept. Using
LDR Sensors and a Piezo Buzzer we can create an Arduino Piano.
+ BONUS: using buzzers we can set an “array” of desired frequencies to implement a theme song
we would like to hear.
7. References
1. https://programmingelectronics.com/an-easy-way-to-make-noise-with-arduino-using-tone/
2. http://www.instructables.com/id/How-to-use-a-photoresistor-or-photocell-Arduino-Tu/