adcIn =
analogRead
(adcPin);
if
(adcIn >=
500
)
digitalWrite
(ledPin,
HIGH
);
// if adc in > 500, led light
else
digitalWrite
(ledPin,
LOW
);
Serial
.
println
(adcIn);
delay
(
100
);
}
4. Open the serial monitor. You should see some data from ADC.
5. Move the lever back and forth. The serial data will change correspondingly.
When the output resistance exceeds a certain preset value, the on-board
indicator LED will also light up.
As an HID Device
Slide Potentiometer can be an effective Human Interface Device (HID) and can be
used, for example, in the radio controller of a Radio Controlled toy car. The picture
below shows two Slide Potentiometers on the control panel - one to control the speed
of the left wheel, and the other to control the speed of the right wheel of the toy car
respectively. Now you can change the speeds of both motors and see the behavior.
You will see that if you make the right wheel spin faster than the left wheel, the car
will turn rightwards, and if you make the left wheel spin faster than the right wheel,
the car will turn leftwards.