Test if five different objects are electrically conductive using a BBC Micro:bit.

On the fifth day of Christmas my true love sent to me
five objects tested
four lines of code
three LEDs in cardboard
two functions in a module
and a micro:bit in a Christmas tree

Firstly, you have to connect a crocodile clip from the 3v pin to a resistor (I used a 470 ohm one) and a crocodile clip to pin 0. Then connect another crocodile clip to the other end of the resistor. Here’s a simple diagram:

|     Micro:bit     |
|   0               3v   |
|_______________|
.     l                 l
.     l               [“]   470 ohm
.     l                 l

Open the Python editor at Microbit.org and copy in the following code:

from microbit import *

while True:
    if pin0.read_digital() == 1:
        display.show(Image.SQUARE)
    sleep (1000)
    display.clear()

All the code above does is constantly check whether electricity is flowing to pin 0. When you place a conductive object between the two ends of the crocodile clips, electricity will flow from the 3v pin to pin 0, making the code run so that the screen on the Micro:bit lights up. If the object isn’t conductive then nothing will happen. Here are the results from the five objects I tested:

img_0819

Have you had any interesting results? Share them in the comments!

Hang on – aren’t apples conductive? Part 2 can be found here, where you’ll make a more accurate version using analog instead of digital.

Advertisements