The micro:bit can detect touch input on pins 0, 1 and 2. You have to complete a connection between one of these pins and the GND pin using your body. In simple terms, touch both GND and the pin. You don't need any special components for this one.
You can do this directly on the micro:bit, but it's more fun to do it with something else. For the test program on this page, I used banana connectors and simply touched the pins. You could connect the touch pin to something conductive, like tin foil, play-doh, or even a piece of fruit. As long as you touch GND when you touch the other object, you should be able to trigger an event on the micro:bit. Alligator/crocodile clips are excellent for this kind of thing.
ProgrammingThis is pretty simple. The top left corner pixel lights if pin0 is touched, the top right if pin1 is touched.
from microbit import * while True: if pin0.is_touched(): display.set_pixel(0,0,9) else: display.set_pixel(0,0,0) if pin1.is_touched(): display.set_pixel(4,0,9) else: display.set_pixel(4,0,0) sleep(10)
- Time to get creative. This feature is fun to explore just to see what you can make into a switch.
- Use some home-made switches to control the movement of a pixel on the matrix.
- Make some big switches, dance mat style. Display an image on the matrix indicating which one to stomp.
- Play the dance game but in a smaller way and without the jumping around. You can make it like Simon Says and include buttons and gestures in the mix.