Scroll Top

Step Counter

Introduction

In this example, we use one of the GoGo Board’s onboard sensors, the inertial measurement unit (IMU), to create a basic step counter.

The IMU is a motion sensor that measures the GoGo Board’s movement. It can tell if the board is tilting (up, down, left, or right), accelerating, shaking, free-falling, or facing up or down.

On top of introducing motion sensing via the onboard IMU, this example also introduces the programming construct of variable manipulation to track the number of steps taken.

Play

Before we get started with making and coding your step counter, let’s use the onboard control menu to try out the IMU. Using the joystick on the right side of the GoGo Board, navigate to the “Test Your Board” screen, pictured below.

The Test Your Board onboard display screen

For this project, we want to look at the section on the top right, labelled “IMU sensor.” Notice how the reading changes as you try tilting your board in different directions, holding it face-up and face-down, and shaking it. It’s useful to get a rough sense for how far you need to tilt or how hard you need to shake in order for the board to properly detect that motion.

Try tilting your board in different directions

Note: as you move and shake the board please hold the board securely and be careful to not accidentally disconnect the USB-C cable.

Make

What you will need:

Hardware

  • A GoGo Board
  • A USB-C cable
  • A power bank
  • Something to attach the GoGo Board to your leg (string, tape, or a pants pocket)
  • A computer with the GoGo Plugin installed, a web browser (to access the code.gogoboard.org website), and a USB port

Software

What you will need (visual, test):
placeholder image for materials list

Here are two questions to think about to guide your making:

  • Where will you place the GoGo Board to accurately capture steps?
  • How will you securely attach the GoGo Board to that location?

Code

Strategy

What are the key elements of a step counter? Here are some suggestions:

  1. Detect when a step has been taken
  2. Keep track of the number of steps that have been taken
  3. Display the number of steps that have been taken
Code Instructions
  1. Create a “steps” variable and set it to 0.
  2. Create a forever-do loop with a 300 ms wait time
  3. Create a an if-do conditional block that increments the “steps” variable each time the GoGo Board detects a “shake” gesture.
  4. Show the number of “steps” on the onboard display.
Blocks
Logo Code to start
set steps 0
set steps (0)
forever
[
if (boardgesture = 8)
[
set steps ( steps + 1 )
]
show steps
wait 300
]
end

Test

Test the accuracy of your step counter:

Try walking with your step counter while counting your steps aloud and check if your number matches the one on the GoGo display. Is it more or less accurate if you jog or run? What about if you change your gait?

Improve:

How might you improve the accuracy of your step counter? One thing to try is looking at your code to see what might be causing it to skip a count or count extra steps in certain cases…In our code example, the loop wait time is set to 300 milliseconds. What happens if you decrease or increase this number?

Extend

Here are some other projects to try that make use of the IMU sensor:

  • Connect a servo motor to your GoGo Board and control it’s direction with tilt.
  • Use the keyboard emulation functions to create a GoGo-powered steering wheel to control Scratch games and animations.
  • Use the free-fall sensing capability of the IMU and the onboard buzzer (or WiFi messaging functions) to create an automatic fall detection medical alert device.