Advertisement
ccarman602

Lesson-4-Buzzer

Nov 25th, 2021 (edited)
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int BuzzerPin = 5;
  2. int Potentiometer = A0;
  3.  
  4. void setup() {
  5.   pinMode(BuzzerPin, OUTPUT);
  6.   pinMode(Potentiometer, INPUT);
  7. }
  8.  
  9. void loop() {
  10.   int potentioValue, Value;
  11.   potentioValue = analogRead(Potentiometer);
  12.   Value = map(potentioValue, 0, 1023, 0, 255); //Mapping potentiometer value to PWM signal value
  13.   analogWrite(BuzzerPin, Value);
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement