How To POT With Buzzer

Required Hardware

For users who do not have Hackerspace Karachi Arduino Kit v1.0

  • Arduino Board
  • Breadboard
  • Resistor 220 ohm
  • Buzzer
  • POT
  • Hook-up Wires

Circuit

For users who do not have Hackerspace Karachi Arduino Kit v1.0

Schematic

Code

                    

1. /*
2. POT with Buzzer
3. This example shows how to use POT with Buzzer.
4.
5. The circuit:
6. – BUZZER
7. Anode connected to analog pin Ao.
8. Cathode connected to Ground.
9. – POT
10. Anode connected to 5v.
11. Signal/Viper connected to analog pin A2.
12. Cathode connected to Ground.
13.
14. http://hackerspacekarachi.org/
15. */
16. #define potPin A2 // POT connected to analog pin A2
17.
18. void setup() {
19. pinMode(A0, OUTPUT); //Declare pins to be used as ouput
20.
21. }
22.
23. void loop()
24. {
25. int potValue = analogRead(potPin); // read analogue value from
potentiometer (0 ~ 1023)
26.
27. int Value = map(potValue, 0, 1023, 0, 255 ); // maps the value from 0 ~ 1023 to 0 ~
255
28.
29. analogWrite(A0, Value); // sets the value (range from 0 to 255)
30.
31. delay(30);
32. }

1. /*