This is a tone selector with the ability to change the buzzer frequency by a potentiometer and to see the result on a 16×2 display.
This is a small tone selector with the ability to change the frequency by a potentiometer and to see the result on a 16×2 display. It also has an automatic testing mode at the beginning.
Please watch the video till the end (less than a minute) to see what it can do
The project is pretty straight forward:
Arduino reads the analog data from the potentiometer and the program transforms it into a frequency to be played by the buzzer (in a range of 20-2000 Hz). The program provides the thresholds on lower and on higher frequencies.
It starts with a test sequence that it sends to the buzzer a wave of notes and then the program listens to the potentiometer values.
The display shows the frequence played at the moment.
I used a trimmer to adjust the display contrast (at the beginning it usually doesn’t show anything because of the too high contrast, so it needs to be adjusted.
The buzzer is a Elegoo passive buzzer connected using only 2 pins as a standard buzzer (so, any buzzer can be used as well).
The potentiometer is a 10Kohm linear and it works pretty well in this range, but I adjusted the scale on the program so to double it because of the original range too low (0-1024).
The arduino Sketch built-in library “Tone” has been used for the buzzer and the LiquidCrystal library for the 16×2 display.
It can be used as a base to learn synth music or to build a proper synth with other controls for changing the basic square wave and to add some loops like in a sequencer.
ARDUINO CODE:
#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int ccc = 1; int sensorPin = A0; int sensorValue = 0; int freq = 0; const int buzzer = 7; void playTone(int freqq){ lcd.clear(); lcd.setCursor(0, 0); lcd.print("Freq"); lcd.setCursor(0, 1); tone(buzzer, freqq); lcd.print(freqq); } void setup() { pinMode(buzzer, OUTPUT); lcd.begin(16, 2); lcd.setCursor(0, 0); lcd.print("Testing..."); delay(1000); for (int freqq = 256; freqq <= 512; freqq++) { playTone(freqq); delay(10); } for (int freqq = 512; freqq >= 256; freqq--) { playTone(freqq); delay(10); } noTone(buzzer); lcd.setCursor(0, 0); lcd.clear(); lcd.print("Ready in 3"); delay(1000); lcd.clear(); lcd.print("Ready in 2"); delay(1000); lcd.clear(); lcd.print("Ready in 1"); delay(1000); } void loop() { sensorValue = analogRead(sensorPin); freq = ceil(sensorValue/5)*5*2; if (freq>2000) { freq = 2000; } if (freq<20) { freq = 20; } playTone(freq); delay(20); }
Assembly List
Label | Part Type | Properties |
---|---|---|
LCD1 | LCD screen 16×2 | type Character; pins 16 |
Part1 | Arduino Uno (Rev3) | type Arduino UNO (Rev3) |
R2 | 330Ω Resistor | package THT; resistance 330Ω; pin spacing 400 mil; bands 4; tolerance ±5% |
R3 | Trimmer Potentiometer | track Linear; size Trimmer – 12mm; package THT; maximum resistance 10kΩ; type Trimmer Potentiometer |
R5 | 220Ω Resistor | package THT; resistance 220Ω; pin spacing 400 mil; bands 4; tolerance ±5% |
R6 | Rotary Potentiometer (Large) | track Linear; size Rotary – 16mm; package THT; maximum resistance 10kΩ; type Rotary Shaft Potentiometer |
SG2 | Buzzer 12mm | size 12mm; package buzzer-12mm-ns; variant ns |
Shopping List
Amount | Part Type | Properties |
---|---|---|
1 | LCD screen 16×2 | type Character; pins 16 |
1 | Arduino Uno (Rev3) | type Arduino UNO (Rev3) |
1 | 330Ω Resistor | package THT; resistance 330Ω; pin spacing 400 mil; bands 4; tolerance ±5% |
1 | Trimmer Potentiometer | track Linear; size Trimmer – 12mm; package THT; maximum resistance 10kΩ; type Trimmer Potentiometer |
1 | 220Ω Resistor | package THT; resistance 220Ω; pin spacing 400 mil; bands 4; tolerance ±5% |
1 | Rotary Potentiometer (Large) | track Linear; size Rotary – 16mm; package THT; maximum resistance 10kΩ; type Rotary Shaft Potentiometer |
1 | Buzzer 12mm | size 12mm; package buzzer-12mm-ns; variant ns |
External links:
http://fritzing.org/projects/tone-selector-with-lcd
https://create.arduino.cc/projecthub/cronenborg/a-tone-generator-with-lcd-display-15012c