Electronic – Microbit GPIO safety

gpiomicrobit

I asked this question on StackOverflow and was told it was more suited to here…

I am getting started using the micro:bit and have just built the micro:bit piano mentioned here: https://www.youtube.com/watch?v=ulKq5To9dmA

I want to get my students to make it in school as a project but I have a few questions about how the circuit works.

The power-supply and earth are both taken off the micro:bit. The 3.3v passes through a 22mOhm resistance in the circuit on the video (and a 100kOhm resistance in my circuit). A wire is inserted between the resistance on the breadboard and the pin from the micro:bit . When this wire is connected to ground (the Piano key and Earth on the diagram), depending on which pin it interrupts, the micro:bit plays a sound.

enter image description here

The questions I have are:

  1. In the code, the GPIO pins are set to a floating state at the start. Would it be safer to set the pins to 1 at the start or would this stop the circuit from working? I don’t know if there is a risk of a stray voltage damaging the board if the pins are in a floating state?

pins.setPull(DigitalPin.P8, PinPullMode.PullNone)
pins.setPull(DigitalPin.P12, PinPullMode.PullNone)
pins.setPull(DigitalPin.P13, PinPullMode.PullNone)
pins.setPull(DigitalPin.P14, PinPullMode.PullNone)
pins.setPull(DigitalPin.P15, PinPullMode.PullNone)
pins.setPull(DigitalPin.P16, PinPullMode.PullNone)

  1. I don’t have a 22megaohm resistor so I used a 100 kilohm resistor, and a stick made of some insulated copper wire in place of my hands to connect the piano key to the ground. I know that you should not connect the 3.3 volt directly to ground on the micro:bit as it my damage it. Is a 100kilohm resistance enough to have between the 3.3 volt supply and the input pins or is there a risk this could also damage the micro:bit? It is putting 33 microamps into the pins.

Thanks for your help.

Best Answer

The 22MOhm resistor is a pull-up so the GPIO isn't floating. The magnitude of the resistance is significant in this instance as you wish to use the human body to ground the GPIO pin and the human body has a resistance of 5MOhm (according to the video you linked @ 3:50). If you use a 100kOhm resistor the voltage at the pin is 3.23V ( R2/(R1+R2)*V = 5M/(100k+5M)*3.3 ) and the microcontroller can't see any change.