COUNT YOUR STEP WITH MICROBIT

COUNT YOUR STEP WITH MICROBIT - Robocraze

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.

Introducing you to our hero of the day, the BBC Micro Bit is a very small ARM Cortex-M0 board designed by BBC which describes it as ‘pocket-sized code-able computer with motion detection, built-in compass, and Bluetooth technology’. It allows us to do all kinds of cool stuff, from building robots to musical instruments. And the best part about it would be the ease of use – it can be coded from any web browser in Blocks, Javascript, Python, Scratch and more; no software required. The main purpose of micro:bit is learning, be it for teachers or students.

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
  • USB interface
  • Use AAA batteries to use your micro bit

BBC 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.


Start exploring now! :)

Reference: microbit.org

 

Components and Supplies

    You may also like to read

    Frequently Asked Questions

    Back to blog

    Leave a comment

    Please note, comments need to be approved before they are published.

    Components and Supplies

      You may also like to read