Software Code
Open Arduino IDE.
Copy the following code, click Verify to check for syntax errors. Verify that there are no
errors, and you can upload the code.
int BuzzerPin = 5;
int Potentiometer = A0;
void setup() {
pinMode(BuzzerPin, OUTPUT);
}
void loop() {
int potentioValue, Value;
potentioValue = analogRead(Potentiometer);
Value = map(potentioValue, 0, 1023, 0, 255); //Mapping potentiometer va
lue to PWM signal value
analogWrite(BuzzerPin, Value);
}