Build a Smart Wheelchair!
A super fun STEM project that helps people with physical challenges move around safely using voice commands and obstacle-sensing superpowers!
🗺️ Overview
⚙️ How the Smart Wheelchair works
🎤 You Speak a Command
The voice recognition module listens for keywords like "forward", "left", "right", or "stop". It converts your spoken word into a digital signal that the Arduino can read over a serial connection.
🧠 Arduino Thinks
The Arduino Uno is the brain of the whole project! In microseconds it reads the voice command, checks both ultrasonic sensors, and decides what to do next. It runs our code 20 times every second!
📡 Sensors Watch for Danger
Two HC-SR04 ultrasonic sensors act like bat ears! They fire invisible sound pulses and measure how long the echo takes to return. If anything is closer than 20 cm — emergency stop, automatically!
⚙️ Motors Move the Wheels
The L298N motor driver translates the Arduino's digital signals into real power for two DC motors. Spin both forward = go forward. Spin one = turn. Stop both = stop. Simple but powerful!
🎓 What you will learn
🛒 Parts List
🔧 Components list
📦 Tools you need
⚡ Circuit
🗺️ Full circuit diagram
📋 Wiring reference table
| Module | Module Pin | → | Arduino Pin |
|---|---|---|---|
| HC-SR04 Front | VCC | → | 5V |
| HC-SR04 Front | GND | → | GND |
| HC-SR04 Front | TRIG | → | D9 |
| HC-SR04 Front | ECHO | → | D10 |
| HC-SR04 Side | TRIG | → | D6 |
| HC-SR04 Side | ECHO | → | D7 |
| Voice Module | TX | → | D2 (RX) |
| Voice Module | RX | → | D3 (TX) |
| L298N Driver | IN1 | → | D4 |
| L298N Driver | IN2 | → | D5 |
| L298N Driver | IN3 | → | D11 |
| L298N Driver | IN4 | → | D12 |
| L298N Driver | OUT1/2 | → | Motor 1 |
| L298N Driver | OUT3/4 | → | Motor 2 |
| Battery 12V | + | → | L298N VCC |
| Battery 12V | − | → | Common GND |
💻 Code
// explains what the code is doing. Read them like a recipe — the Arduino follows every step perfectly!📥 Upload instructions
- Download and install Arduino IDE from arduino.cc
- Plug your Arduino Uno into the computer via USB
- Go to Tools → Board → Arduino Uno
- Go to Tools → Port → select your COM port
- Copy the code below, paste it in the IDE, click ➤ Upload
- Open Serial Monitor (magnifier icon) at 9600 baud
- You should see:
🦽 Smart Wheelchair Ready!
🤖 Arduino code — smart_wheelchair.ino
// ============================================================ // 🦽 SMART WHEELCHAIR — Arduino Code // For kids learning assistive technology! // Controls: Voice commands + Obstacle sensors // ============================================================ #include <SoftwareSerial.h> // ── 🎤 VOICE MODULE ────────────────────────────────────────── // Pins: 2 = RX (receive), 3 = TX (transmit) SoftwareSerial voiceSerial(2, 3); // ── 📡 FRONT ULTRASONIC SENSOR (HC-SR04) ───────────────────── const int FRONT_TRIG = 9; // Sends the sound pulse const int FRONT_ECHO = 10; // Receives the echo // ── 📡 SIDE ULTRASONIC SENSOR (HC-SR04) ────────────────────── const int SIDE_TRIG = 6; const int SIDE_ECHO = 7; // ── ⚙️ MOTOR DRIVER PINS (L298N) ───────────────────────────── const int IN1 = 4; // Left motor — forward const int IN2 = 5; // Left motor — backward const int IN3 = 11; // Right motor — forward const int IN4 = 12; // Right motor — backward // ── 🚧 SAFETY DISTANCE ─────────────────────────────────────── // Stop if anything is closer than 20 centimetres! const int SAFE_DISTANCE = 20; // ── 🧠 SETUP — runs once at start ──────────────────────────── void setup() { // Start communication channels Serial.begin(9600); // Computer serial (for debugging) voiceSerial.begin(9600); // Voice module serial // Configure motor pins as outputs pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); // Configure sensor pins pinMode(FRONT_TRIG, OUTPUT); pinMode(FRONT_ECHO, INPUT); pinMode(SIDE_TRIG, OUTPUT); pinMode(SIDE_ECHO, INPUT); // Start safe — motors off stopMotors(); Serial.println("🦽 Smart Wheelchair Ready!"); Serial.println("Commands: forward | left | right | stop"); } // ── 📏 getDistance() — measure distance using sound ────────── // How it works: // 1. Fire a 10-microsecond sound pulse from TRIG pin // 2. Measure how long ECHO pin stays HIGH (time for echo) // 3. Distance (cm) = time × speed_of_sound / 2 long getDistance(int trigPin, int echoPin) { digitalWrite(trigPin, LOW); delayMicroseconds(2); // Settle digitalWrite(trigPin, HIGH); delayMicroseconds(10); // 10µs pulse digitalWrite(trigPin, LOW); long duration = pulseIn(echoPin, HIGH); // Measure echo return duration * 0.034 / 2; // Convert to cm } // ── ⬆️ moveForward() — both motors spin forward ────────────── void moveForward() { digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); // L: forward digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); // R: forward Serial.println("⬆️ Moving FORWARD"); } // ── ⬇️ moveBackward() — both motors spin backward ──────────── void moveBackward() { digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); // L: backward digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH); // R: backward Serial.println("⬇️ Moving BACKWARD"); } // ── ⬅️ turnLeft() — right motor on, left motor off ─────────── void turnLeft() { digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); // L: stop digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW); // R: forward Serial.println("⬅️ Turning LEFT"); } // ── ➡️ turnRight() — left motor on, right motor off ────────── void turnRight() { digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); // L: forward digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); // R: stop Serial.println("➡️ Turning RIGHT"); } // ── 🛑 stopMotors() — EVERYTHING stops immediately ─────────── void stopMotors() { digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); digitalWrite(IN3, LOW); digitalWrite(IN4, LOW); } // ── 🔄 LOOP — repeats 20 times per second! ─────────────────── void loop() { // Step 1: Read both ultrasonic sensors long frontDist = getDistance(FRONT_TRIG, FRONT_ECHO); long sideDist = getDistance(SIDE_TRIG, SIDE_ECHO); // Step 2: SAFETY CHECK — obstacle overrides everything! if (frontDist < SAFE_DISTANCE || sideDist < SAFE_DISTANCE) { stopMotors(); Serial.print("🚧 OBSTACLE! Front: "); Serial.print(frontDist); Serial.print("cm Side: "); Serial.print(sideDist); Serial.println("cm — Stopping!"); return; // Skip voice check this cycle } // Step 3: Check if a voice command has arrived if (voiceSerial.available() > 0) { String command = voiceSerial.readStringUntil('\n'); command.trim(); // Remove spaces/newlines command.toLowerCase(); // Case-insensitive Serial.print("🎤 Heard: "); Serial.println(command); // Step 4: Act on the command! if (command == "forward") { moveForward(); } else if (command == "backward") { moveBackward(); } else if (command == "left") { turnLeft(); } else if (command == "right") { turnRight(); } else if (command == "stop") { stopMotors(); } else { Serial.println("❓ Unknown — try: forward/backward/left/right/stop"); } } delay(50); // Wait 50ms, then repeat the loop! } // ============================================================ // 🎉 That's the complete Smart Wheelchair code! // 5 movement functions + safety sensor check // Loop runs ~20 times per second — super fast! // ============================================================
🧪 Test It!
✅ Testing checklist
-
1
📡 Test the sensors alone
Open Serial Monitor after uploading the code. Put your hand 10 cm in front of the front sensor. You should see
🚧 OBSTACLE! Front: 9cmprinted. Move your hand — the number should change. Both sensors must work before moving on! -
2
⚙️ Test the motors (without wheels)
Type
forwardinto Serial Monitor and press Enter. Both motors should hum and spin. Tryleft— only the right motor should spin. Tryright— only left motor. Trystop— both stop. -
3
🎤 Test the voice module
Speak "forward" clearly toward the voice module. Watch the Serial Monitor — it should print
🎤 Heard: forwardand the motors should spin. Test all 5 commands: forward, backward, left, right, stop. -
4
🚧 Test obstacle safety stop
Say "forward" to start moving, then quickly put your hand in front of the front sensor. The wheels must stop automatically! This is the most important safety feature — it must work every single time.
-
5
🎉 Full system test — time to roll!
Attach wheels to the motors. Test the full sequence: say "forward" → say "left" → say "forward" → say "right" → say "stop". Navigate through an obstacle course. Congratulations — you built a Smart Wheelchair! 🦽✨
🚀 Level up ideas
You did it!
You just built a real assistive technology device — the kind that changes lives! Share your creation with friends and family. You're a maker! 🦾
🌐 Share on Arduino Hub
Comments
Post a Comment