Want to keep a track of your fitness? Need a temperature sensor? Or maybe just a click a remote selfie, without giving that confounded selfie expression in your click. No worries, you can do it all with a single device and, that too at a very affordable price.
An overview of the device in hand:
25 individually-programmable LEDs
2 programmable buttons
Physical connection pins
Light and temperature sensors
Motion sensors (accelerometer and compass)
Wireless Communication, via Radio and Bluetooth
Use AAA batteries to use your micro bit
Now, let’s get started with a project - DIY STEP COUNTER BBC has been really generous in providing us with so many on-board hardware. To make the Step-Counter, we will make use of the accelerometer to detect and count the shakes/jerks which are produced with each step. First, when we plug in our device using micro USB, it runs a set program – displays a heart shape in the 5x5 LED matrix, press the push buttons A and B, shake the micro:bit and chase a dot by tilting the device in the required direction. This is something which would have already got you interested in this tiny device.
To code, the Step Counter, go to www.microbit.org website and click on the ‘Let’s code’ tab. You will be shown multiple options in which you can code in. We choose Python, and the editor opens with a default program. Delete the existing code and enter the code below:
from microbit import*
#Define a variable to record steps steps = 0
while True: # Check to see if a step has been taken. If so, display a smile and increase the number of steps by 1 if accelerometer.was_gesture('shake'): steps += 1 display.show(Image.HAPPY) sleep(500) display.clear()
# Check to see if button A has been pressed. If so, display the number of steps taken if button_a.is_pressed(): string_steps = str(steps) display.show(string_steps) sleep(500) display.clear()
After you are done with the code, download and copy the HEX file into the micro:bit storage. The micro:bit will restart with your updated code. The code is easy to understand. But in case you need our help, check out our video for the explanation! :)
There are so many things that can be done with micro:bit, that you need to start exploring right away! Buy this cool little tiny gadget here.