o
Similarly, you can use the slide potentiometer to vary the speed of your
or the frequency with which your
o
The slide potentiometer can also be used as an ON/OFF switch for any circuit.
Take the slider to the Vcc position to switch it ON and move it down to GND to
switch OFF a circuit.
In terms of choosing a power module, you can use either the
module for building standalone Grove
circuits.
As a Voltage Divider
Follow these simple steps to make the slide potentiometer module function as a
voltage divider:
1. When using the module in conjunction with an
, use
and connect the Grove - Slide Potentiometer module
to the shield using a designated Grove Interface (e.g., Analog Port 0 as shown
below):
2. Connect the board to PC using USB cable
3. Upload the following sample sketch:
int
adcPin = A0;
// select the input pin for the potentiometer
int
ledPin = A1;
// select the pin for the LED
int
adcIn =
0
;
// variable to store the value coming from the sensor
void
setup
()
{
Serial
.
begin
(
9600
);
// init serial to 9600b/s
pinMode
(ledPin,
OUTPUT
);
// set ledPin to OUTPUT
Serial
.
println
(
"Sliding Potentiometer Test Code!!"
);
}
void
loop
()
{
// read the value from the sensor: