Arduino Nano 33 IoT Motion Visualizer with LSM6DS3 and OLED SSD1306

Discover how to build a real-time motion visualizer using the Arduino Nano 33 IoT, its internal LSM6DS3 accelerometer and gyroscope, and an OLED SSD1306 display. This project is perfect for electronics enthusiasts, students, and makers who want a fun and interactive way to visualize movement.

Discover how to build a real-time motion visualizer using the Arduino Nano 33 IoT, its internal LSM6DS3 accelerometer and gyroscope, and an OLED SSD1306 display. This project is perfect for electronics enthusiasts, students, and makers who want a fun and interactive way to visualize movement.

What You Will Learn

  • Tips to make your project video-ready with smooth animations.
  • How to read accelerometer data from the internal LSM6DS3 IMU.
  • How to map accelerometer values to an OLED display for visual feedback.
  • How to create a dynamic ball that moves based on device tilt.
  • How to animate a radar-like visualization when the device is idle.

PCBWay now offers a free purple solder mask at no extra charge, making your boards stand out in style. PCBWay provides high-quality PCB prototyping and assembly at an affordable price, starting at just $5 for 5 PCBs. With fast turnaround, great customer support, and easy online ordering, it’s a top choice for hobbyists and professionals alike.

Hardware Components

You’ll need the following hardware components to get started:

QuantityComponentDescription
1Arduino Nano 33 IoTMicrocontroller with internal LSM6DS3 IMU
1SSD1306 OLED Display 128×64I²C interface, monochrome OLED
VariousJumper wiresFor connections between Arduino and OLED
1BreadboardOptional, for prototyping

Schematic

Make connections according to the circuit diagram given below.

Wiring / Connections

OLED PinArduino Nano 33 IoT
VCC3.3V
GNDGND
SDAA4
SCLA5

Arduino Code

This code creates a motion visualizer with radar animation:

  • The ball moves based on the device tilt.
  • When the device is idle, a radar sweep animates.
  • Motion above a certain threshold triggers a “Motion Detected!” display.
#include <Wire.h>
#include <Arduino_LSM6DS3.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <math.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

float angle = 0;           // Radar sweep angle
const int radarRadius = 30;
const int centerX = SCREEN_WIDTH/2;
const int centerY = SCREEN_HEIGHT/2;

// Motion detection threshold
const float motionThreshold = 0.15;

void setup() {
  Serial.begin(9600);

  // Initialize IMU
  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    while(1);
  }

  // Initialize OLED
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("SSD1306 allocation failed");
    for (;;);
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(10, 0);
  display.println("Motion Visualizer");
  display.display();
  delay(800);
}

void loop() {
  float xAcc, yAcc, zAcc;
  bool motionDetected = false;

  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(xAcc, yAcc, zAcc);

    // Calculate overall acceleration magnitude
    float magnitude = sqrt(xAcc*xAcc + yAcc*yAcc + zAcc*zAcc);

    // Detect motion
    motionDetected = magnitude > motionThreshold;

    display.clearDisplay();

    if(motionDetected){
      // Display motion detected text
      display.setTextSize(2);
      display.setCursor(10, SCREEN_HEIGHT/2 - 10);
      display.println("Motion Detected!");
    } else {
      // Radar animation
      display.drawCircle(centerX, centerY, radarRadius, SSD1306_WHITE);
      display.drawCircle(centerX, centerY, radarRadius-5, SSD1306_WHITE);

      int x = centerX + radarRadius * cos(angle);
      int y = centerY + radarRadius * sin(angle);
      display.drawLine(centerX, centerY, x, y, SSD1306_WHITE);

      angle += 0.1;
      if(angle > 2*3.14159) angle = 0;

      // Draw radar center
      display.fillCircle(centerX, centerY, 2, SSD1306_WHITE);
    }

    display.display();
  }

  delay(30);
}

Conclusion

In this tutorial, you built a dynamic motion visualizer using the Arduino Nano 33 IoT, its internal LSM6DS3 IMU, and an SSD1306 OLED display.

This project demonstrates:

  • How to read accelerometer data from the Nano 33 IoT.
  • How to map real-world motion into a visual display.
  • How to implement a radar-style idle animation for a professional look.
  • Techniques to make electronics projects visually engaging for videos or demos.

This setup is perfect for beginners and hobbyists who want to learn about IMU sensors, real-time visualization, and interactive electronics projects. You can expand it further by adding motion-triggered alerts, sound effects, or even web-based monitoring for a complete IoT motion detection system.

If you liked this project, follow more on circuit-diy.com for tutorials, projects, and practical circuits for makers like you!