When you press on different parts of the soft potentiometer, you vary its resistance. The readings vary from low at one end to high at the other. You can trigger change in resistance by pressing with your finger or by moving a plastic or metal clip.
Here is the kind of circuit that you need. The 10K ohm resistor connects the signal line to GND.
This is a simple program so that you can watch the readings that you get in the REPL window.
from microbit import * while True: x = pin0.read_analog() print(x) sleep(50)
It's quite hard to be precise when you press the softpot. You can be quite effective when dealing with ranges of values though. I get a low reading of 5 when nothing is touching the sensor. I get under a hundred when touching the right end and around 1000 at the end near the pins.
- Your first challenge is to respond to the presses, rather like buttons. Treat ranges of values like they are button presses. You can do this with IF statements or you can do it mathematically. Find out about floor division and divide the reading by say, 250. Output the result of this.
- What happens if you press more than one part of the sensor.
- If you store readings over time (say the last 10), you can respond to gestures like sliding a finger from left to right.
- Attach a buzzer to the circuit and make some noise. Concentrate on a relatively small number of possible notes for more controllable output or let the numbers run wild to give weird sounds.
- Light up different parts of the LED matrix depending on where the softpot is pressed.
- Use the softpot reading to determine the position of a pixel on the LED matrix. You should be able to make it controllable on a single axis.