Menu
Microbots
0
  • Robots & Kits
    • ProtoBot
    • CubeBot
    • Robot Parts
  • Modules & Parts
    • CodeCell ESP32 Modules
    • Motors & Actuators
    • LiPo Batteries
  • Gear
    • Tools
    • Merch
  • Learn
    • User Guide & Tutorials
    • DIY Projects & Files
    • Education Discounts
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Sign in
  • Your Cart is Empty
Microbots
  • Robots & Kits
    • ProtoBot
    • CubeBot
    • Robot Parts
  • Modules & Parts
    • CodeCell ESP32 Modules
    • Motors & Actuators
    • LiPo Batteries
  • Gear
    • Tools
    • Merch
  • Learn
    • User Guide & Tutorials
    • DIY Projects & Files
    • Education Discounts
  • About
    • Our Story
    • Reach Out
    • FAQs
  • 0 0

CodeCell: Making a Step Counter

CodeCell Step Counter

CodeCell includes a built-in BNO085 motion sensor capable of detecting and counting steps using onboard activity algorithms. In this example, you’ll learn how to use the CodeCell Library to read step counts and display them on an OLED screen, turning your CodeCell into a tiny pedometer or wearable fitness tracker.

How Steps Are Counted

The BNO085 fuses data from its accelerometer, gyroscope, and magnetometer to recognize walking or running patterns and generate accurate step counts. You can read the total step count at any time with a single function:

uint16_t steps = myCodeCell.Motion_StepCounterRead();

To enable this mode, initialize motion sensing with:

myCodeCell.Init(MOTION_STEP_COUNTER);

Once initialized, CodeCell continuously tracks steps internally and updates the count whenever you call the function above.

Example – Display Step Count on OLED

This example reads the live step count and displays it on a small OLED screen (SSD1306). Connect your OLED’s GND, 3V3, SDA, and SCL pins to the lower side of CodeCell.


#include <CodeCell.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

CodeCell myCodeCell;

/* OLED Display Configuration */
#define SCREEN_WIDTH 64
#define SCREEN_HEIGHT 32
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

uint16_t step_counter = 0;

void setup() {
  Serial.begin(115200);
  myCodeCell.Init(MOTION_STEP_COUNTER);  // Enable step counter mode

  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println("Display Error");
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.display();
  delay(2000);
}

void loop() {
  if (myCodeCell.Run(10)) {              // Run loop at 10 Hz
    step_counter = myCodeCell.Motion_StepCounterRead();  // Read step count

    display.clearDisplay();
    display.setCursor(5, 16);
    display.print(F("Steps: "));
    display.print(step_counter);
    display.display();
  }
}

Customization Tips

  • Add goals: Set daily targets or use LED feedback when reaching milestones.
  • Track activity time: Combine with CodeCell’s MOTION_ACTIVITY mode for walking or running detection.
  • Store data: Log steps to EEPROM or send them over Bluetooth for wearable applications.

 

  • Share:

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2026 Microbots.

★ Reviews

Let customers speak for us

86 reviews
Write a review
87%
(75)
5%
(4)
2%
(2)
2%
(2)
3%
(3)
80
21
A
ProtoBot
Anonymous

This is a great product for beginners who want hands-on experience with Arduino and 3D printing. The Protobot has a sleek, solid design, and the software is just as polished. I’ve bought several educational robotics kits, and this is the best one so far. Looking forward to more awesome products!

F
ProtoBot
Francis van Uyten

Really love this robot. I like that is simple to assemble and I like that you guys prepares it easy to start programming with examples and libraries. My opinion on what to improve is more like a add-on, can you guys develop a localisation sensor or function so it will know where the bot is. Expecting only great things coming from you guys. Succes

G
Experiment in Progress Mug
Gerald Kendrick

I am enjoying my Experiment in Progress coffee mug. It fits in well in the lab.

K
12-in-1 Screwdriver (Pen-Size)
Klaas

Very useful fun little screwdriver for the all tiny stuff

f
ProtoBot
frederic marty

I don't have much time right now to test the micro bot, but it looks good.