Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
RGB Backlight LCD - 16x2
Resistor 221 ohm
Resistor 330 ohm
Breadboard (generic)
Buzzer
Rotary potentiometer (generic)
Trimmer
Project description
Code
Arduino Code
arduino
1#include <LiquidCrystal.h> 2 3LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 4int ccc = 1; 5int sensorPin = A0; 6int sensorValue = 0; 7int freq = 0; 8const int buzzer = 7; 9 10void playTone(int freqq){ 11 lcd.clear(); 12 lcd.setCursor(0, 0); 13 lcd.print("Freq"); 14 lcd.setCursor(0, 1); 15 tone(buzzer, freqq); 16 lcd.print(freqq); 17} 18 19void setup() { 20 pinMode(buzzer, OUTPUT); 21 lcd.begin(16, 2); 22 lcd.setCursor(0, 0); 23 lcd.print("Testing..."); 24 delay(1000); 25 for (int freqq = 256; freqq <= 512; freqq++) { 26 playTone(freqq); 27 delay(10); 28 } 29 for (int freqq = 512; freqq >= 256; freqq--) { 30 playTone(freqq); 31 delay(10); 32 } 33 noTone(buzzer); 34 lcd.setCursor(0, 0); 35 lcd.clear(); 36 lcd.print("Ready in 3"); 37 delay(1000); 38 lcd.clear(); 39 lcd.print("Ready in 2"); 40 delay(1000); 41 lcd.clear(); 42 lcd.print("Ready in 1"); 43 delay(1000); 44} 45 46void loop() { 47 sensorValue = analogRead(sensorPin); 48 freq = ceil(sensorValue/5)*5*2; 49 if (freq>2000) { 50 freq = 2000; 51 } 52 if (freq<20) { 53 freq = 20; 54 } 55 playTone(freq); 56 delay(20); 57} 58
Downloadable files
schematics
schematics

schematics
schematics

Comments
Only logged in users can leave comments