Pavel_N
Published © GPL3+

Control KY-006 Buzzer with Potentiometer

How to control a buzzer using a potentiometer.

BeginnerFull instructions provided3,928
Control KY-006 Buzzer with Potentiometer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Buzzer
Buzzer
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

KY-006 buzzer

...

Code

KY-006 buzzer

Arduino
int buzzer = 10;
int pot = A0;
int x;
void setup() {
  // put your setup code here, to run once:
  pinMode(buzzer,OUTPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  x = analogRead(pot) / 102,4;

  Serial.println(x);
  digitalWrite(buzzer, HIGH);
  delay(x);
  digitalWrite(buzzer, LOW);
  delay(x);
}

Credits

Pavel_N
0 projects • 0 followers

Comments