I was spring cleaning recently (Spring 2018) going through all the cool micro:bit stuff that I still have lying around. I’d given most of it away to a very good cause, and was preparing a final care package of my remaining swag.
I came across this little beauty that I remember buying from Paul from Pimoroni at a gig in Manchester library (note: Paul ALWAYS brings really cool tech to the events he attends, and sells it at prices that feel like a give-away – I think I paid a squid or less for this!):
Perfect for numeric input, something micro:bit is not very good at! It sat on my to-do list since the day I bought it, and when I came across it in the clean up I couldn’t resist rigging it up – thought I’d knock up a quick calculator app.
I mean, how hard could it be? There are 8 connectors supporting 16 buttons: there are 4 columns and 4 rows and each row and column has a connector. All I needed to do was hook them up to IO pins, read whether each was on or off then check the 16 different cases of the resulting truth table. Wouldn’t even need to be clever – trial and error with 16 if statements would do!
Anyway, easter long weekend meant I had time off work, so sat down to knock it out, expecting it to take a morning at most. Straight away I hit my first stumbling block. Trying to use digital read on the pins did not work reliably for me.
Disclaimer: you might be able to get it working no problem. I have no real knowledge of the subtleties here so I couldn’t troubleshoot. For me, the digital reads did not get picked up with any reliability, and I had to abandon the idea of using 8 digital pins and being finished in time for lunch!
Button presses were registering on the analog pins when using analog read but were not registering a Boolean event when a digital read was used. In many cases the analog perturbations were very small though (say, 25% of the at-rest value – I assumed this was why digital read was not registering a change). That small analog perturbation was enough to register a key press event though – I was going to read that damn keypad one way or another!