Purpose
In this lesson, you will learn how to read the values from a Potentiometer and use those values to move a servo. Potentiometer is a resistor that can be used to adjust motor speed or be used as a dial to move servo motors in one direction or another.
Understanding potentiometers - (USE THE YELLOW PINS FOR THIS SENSOR)
A potentiometer is a special type of resistor. By rotating the knob of the potentiometer you can vary the amount of resistance (see image below).
Step 1: Make sure that the pins on the Potentiometer are facing you and the knob is pointed up.
Step 2: Connect the far right pin on the Potentiometer to "GND" or black pins on the Micro:Bit Board.
Step 3: Connect the far left pin on the Potentiometer to "VSS" or red power on the Micro:Bit Board.
Step 4: Connect the middle pin on the Potentiometer to "10" or (3,4,10) yellow pin on the Micro:Bit Board.
Note: Those are the only Analog pins. No other pin will work.
Step 5: Open the MakeCode editor at https://makecode.microbit.org/.
Step 6: Create a variable called "turn".
Step 7: Click on Pins and select analog read.
Step 8: Finish the remainder of the test code to see if you see values.
Step 9: Example: Read the vales from a Potentiometer and turn a servo motor accordingly. Note connect a servo to the row of pins (3) and the potentiometer to pins (10). Make sure you set the pin for the servo to (3) and the pin for the potentiometer to (10).