BBC micro:bit
Soft Potentiometer

Introduction

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.

Soft Potentiometer

Circuit

Here is the kind of circuit that you need. The 10K ohm resistor connects the signal line to GND.

Soft Potentiometer Circuit

Programming

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.

Challenges

  1. 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.
  2. What happens if you press more than one part of the sensor.
  3. If you store readings over time (say the last 10), you can respond to gestures like sliding a finger from left to right.
  4. 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.
  5. Light up different parts of the LED matrix depending on where the softpot is pressed.
  6. 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.