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);
}
26
Grove Beginner Kit For Arduino
®
Содержание Grove Beginner Kit
Страница 1: ...Grove Beginner Kit For Arduino User Manual ...
Страница 63: ...62 Grove Beginner Kit For Arduino ...