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
| Quantity | Component | Description |
|---|---|---|
| 1 | Arduino Nano 33 IoT | Microcontroller with internal LSM6DS3 IMU |
| 1 | SSD1306 OLED Display 128×64 | I²C interface, monochrome OLED |
| Various | Jumper wires | For connections between Arduino and OLED |
| 1 | Breadboard | Optional, for prototyping |
Schematic
Wiring / Connections
| OLED Pin | Arduino Nano 33 IoT |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | A4 |
| SCL | A5 |
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!