zayedalam
Published © MPL-2.0

Controling sound using potentiometer and button

Hi guys! As always, I have created a fun and a simple project by just using buzzer and potentiometer

BeginnerFull instructions provided1,157
Controling sound using potentiometer and button

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
Or any version of arduino
×1
Buzzer
Buzzer
×1
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×1
Breadboard (generic)
Breadboard (generic)
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 100k ohm
Resistor 100k ohm
×1
Resistor 100 ohm
Resistor 100 ohm
×1

Story

Read more

Schematics

Here is the schematics

Code

Here is the code

Arduino
const int buzzer=9;
int potpin=0;
int button=3;
int buttonState1=0;
 int val=0;
void setup() {
  // put your setup code here, to run once:
pinMode(buzzer,OUTPUT);
Serial.begin(9600);
pinMode(button,INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
buttonState1 = digitalRead(button);
val=analogRead(potpin);
Serial.println(val);
tone(buzzer,val);
if(buttonState1==HIGH){
  tone(buzzer,200);
  delay(20);
  noTone(buzzer);
}

}

Credits

zayedalam
7 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.