cronenborg
Published © CC BY

A Tone Generator With LCD Display!

This is a tone selector with the ability to change the buzzer frequency by a potentiometer and to see the result on a 16x2 display.

BeginnerFull instructions provided12,572
A Tone Generator With LCD Display!

Things used in this project

Hardware components

RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
10kOhm linear
×1
Trimmer
×1
Buzzer
Buzzer
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

schematics

Code

Arduino Code

Arduino
#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);
}

Credits

cronenborg

cronenborg

0 projects • 2 followers

Comments