START_OFFLINE_LAB_SUITE.batAll three classes are aligned on the same 4-day project cycle:
| Day | Date | Milestone Topic | Key Activities |
|---|---|---|---|
| Day 1 | Today (20 Nov) | Motor Driver & Soldering | L298N Dual H-Bridge Intro, Motor Wire Soldering, Direction & PWM Speed Control |
| Day 2 | Saturday (21 Nov) | Chassis Assembly | 2WD/4WD Chassis mechanical assembly, wheel fitment, battery holder & board mounting |
| Day 3 | Monday (22 Nov) | PC / Serial Controlled Car | Control car motors via Serial Monitor / Keyboard ('F', 'B', 'L', 'R', 'S') |
| Day 4 | Tuesday (23 Nov) | Smart Obstacle Avoider | Ultrasonic HC-SR04 + SG90 Servo radar mount, auto-distance detection & steering away |
If any class could not complete the 180° Ultrasonic Radar yesterday due to time or wiring:
1. First 40 Minutes: Rapid completion of the Radar. Check servo on Pin 9 (or GPIO 4), HC-SR04 on Trig/Echo, and test live scope on the offline HTML dashboard (satpuda_radar_dashboard.html).
2. Final 45 Minutes: Transition immediately to Motor Wire Soldering Station. Let students solder the wires to their 2 DC gear motors, test motor spin directly on battery, and store safely in their kit box.
3. Note: In this case, L298N driver wiring moves to tomorrow's first half before chassis mounting.
Every student and lab mentor MUST memorize and follow these 5 fundamental electronics rules before switching on any DC motor circuit:
The 18650 Battery GND (-), L298N GND terminal, and Arduino GND pin MUST all be connected together. Without a shared ground return path, logic voltages float, causing Arduino resets and erratic motor jerking.
Keep the black 2-pin 5V jumper ON when your motor battery is between 7V and 12V (e.g., 2S Li-ion 7.4V). In this mode, the onboard 78M05 regulator generates a stable 5V output that can power your Arduino. If you ever use >12V, remove this jumper immediately to avoid overheating the regulator!
Never rely on molten solder to hold a vibrating motor wire! Strip 5mm of insulation, thread the copper through the motor terminal eyelet, crimp it tightly with pliers to form a mechanical hook, and only then apply solder for 2-3 seconds at 350°C. Finish with heat-shrink tubing.
Never command a motor directly from Forward to Reverse at full speed! Always call stopMotors() with a delay(50) to delay(100) pause. Instant reversals produce huge inductive voltage spikes (counter-EMF) and strip delicate plastic gearbox teeth.
If one wheel turns backward during testing, DO NOT desolder the motor wires! Simply swap the two wires at the L298N green screw terminal (OUT1/OUT2 or OUT3/OUT4) or swap the digital pin logic (HIGH <-> LOW) in your Arduino code.
+-----------------------------------------------------------------------------------+
| CONNECT ROBO - SMART CAR SYSTEM ARCHITECTURE |
| (DAY 1: POWER & MOTORS) |
+-----------------------------------------------------------------------------------+
[ 2x 18650 Li-ion Battery Pack (7.4V) ]
(+) Red Wire (-) Black Wire
| |
[Power Switch] |
| |
v v
+------------------------------------+
| 12V GND 5V (out) | <-- L298N Power Terminal Block
| | | | |
| | +-------------+-------+-----> Common GND to Arduino Uno GND
| | |
| | +-------------> 5V to Arduino VIN (Optional standalone)
| |
| +---------------------------------+
| | L298N DUAL H-BRIDGE DRIVER |
| | |
| | [ENA] [IN1] [IN2] [IN3] [IN4] [ENB] (Logic Input Pins)
| | | | | | | |
| | | | | | | |
| | OUT1 OUT2 OUT3 OUT4
| +----+-----+-----------------+----+
| | | | |
+-------+-----+-----------------+----+
| | | |
v v v v
[ LEFT TT MOTOR ] [ RIGHT TT MOTOR ]
(Gearbox M1) (Gearbox M2)
ARDUINO UNO R3 PIN CONNECTIONS
+-----------------------------------------------------------------------+
| Arduino Pin | L298N Header Pin | Function |
|-------------+------------------+--------------------------------------|
| Pin D5 | ENA (PWM) | Left Motor Speed (Remove ENA Jumper) |
| Pin D8 | IN1 (Digital) | Left Motor Direction Forward |
| Pin D9 | IN2 (Digital) | Left Motor Direction Reverse |
| Pin D10 | IN3 (Digital) | Right Motor Direction Forward |
| Pin D11 | IN4 (Digital) | Right Motor Direction Reverse |
| Pin D6 | ENB (PWM) | Right Motor Speed (Remove ENB Jumper)|
| GND | GND (Terminal) | MANDATORY COMMON GROUND REFERENCE |
+-----------------------------------------------------------------------+
Complete this safety check with your lab partner before turning ON the battery switch:
A microcontroller pin can only supply ~20mA to 40mA of current, whereas a DC gear motor requires 300mA to 1.5A under load. Connecting a motor directly to an Arduino or ESP32 pin will burn the microcontroller! The L298N Motor Driver acts as a heavy-duty current amplifier using 4 internal switching transistors arranged like the letter "H".
+12V Power
| |
[SW 1] [SW 2]
| |
+--[MOTOR]--+
| |
[SW 3] [SW 4]
| |
GND GND
| ENA / ENB | IN1 / IN3 | IN2 / IN4 | Motor Motion | Visual Indicator |
|---|---|---|---|---|
| HIGH (or PWM > 0) | HIGH | LOW | Forward ā© | Green LED on L298N |
| HIGH (or PWM > 0) | LOW | HIGH | Reverse / Backward āŖ | Red LED on L298N |
| HIGH | LOW | LOW | Motor Stop (Coast) š | Both LEDs OFF |
| HIGH | HIGH | HIGH | Brake (Hold) ā” | Both LEDs ON |
| LOW (0) | Any | Any | Motor Disabled š¤ | No current to motor |
[!IMPORTANT] COMMON GROUND RULE: You MUST connect the GND of your Battery Pack to the GND terminal of the L298N AND connect a jumper wire from the L298N GND to the GND of your Arduino / ESP32! Without a common ground reference, the control signals will float and motors will twitch uncontrollably.
| L298N Module Pin | Wire Color | Arduino Uno Pin | ESP32-S3 Pin | Function / Purpose |
|---|---|---|---|---|
| 12V / Power In | Heavy Red | Battery (+) 6Vā12V | Battery (+) 6Vā12V | Main motor driving power |
| GND / Power Ground | Heavy Black | Battery (-) & Uno GND | Battery (-) & S3 GND | Common Ground Reference |
| 5V Output | Thin Red | Unconnected (or 5V if no jumper) | Unconnected | Powers logic (keep jumper ON) |
| ENA (Enable Left) | Yellow | Pin 5 (PWM) | GPIO 6 (PWM) | Left Motor Speed Control |
| IN1 (Left Dir A) | Orange | Pin 6 | GPIO 7 | Left Motor Direction 1 |
| IN2 (Left Dir B) | Green | Pin 7 | GPIO 15 | Left Motor Direction 2 |
| IN3 (Right Dir A) | Blue | Pin 8 | GPIO 16 | Right Motor Direction 1 |
| IN4 (Right Dir B) | Purple | Pin 9 | GPIO 17 | Right Motor Direction 2 |
| ENB (Enable Right) | White | Pin 10 (PWM) | GPIO 18 (PWM) | Right Motor Speed Control |
| OUT1 & OUT2 | Motor Wires | Left DC Motor (+/-) | Left DC Motor (+/-) | Motor Left Terminal Block |
| OUT3 & OUT4 | Motor Wires | Right DC Motor (+/-) | Right DC Motor (+/-) | Motor Right Terminal Block |
This sketch exercises all motor movements: Forward, Backward, Pivot Left, Pivot Right, and Stop.
/*
* Connect Robo - Satpuda STEM Lab (Day 3)
* Code 1: L298N Dual DC Motor Basic Direction Test
* Hardware: Arduino Uno + L298N Motor Driver + 2x TT Gear Motors
*/
// Left Motor Control Pins
const int ENA = 5; // Speed (PWM)
const int IN1 = 6; // Direction A
const int IN2 = 7; // Direction B
// Right Motor Control Pins
const int IN3 = 8; // Direction A
const int IN4 = 9; // Direction B
const int ENB = 10; // Speed (PWM)
void setup() {
Serial.begin(9600);
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
// Set default speed to 75% power (approx 190 out of 255)
analogWrite(ENA, 190);
analogWrite(ENB, 190);
Serial.println("==========================================");
Serial.println("Connect Robo: L298N Motor Test Ready!");
Serial.println("Motors will cycle: FWD -> REV -> LEFT -> RIGHT -> STOP");
Serial.println("==========================================");
}
void forward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
Serial.println("Action: FORWARD ā©");
}
void backward() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
Serial.println("Action: BACKWARD āŖ");
}
void turnLeft() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
Serial.println("Action: PIVOT LEFT āŗ");
}
void turnRight() {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
Serial.println("Action: PIVOT RIGHT ā»");
}
void stopMotors() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
Serial.println("Action: STOP š");
}
void loop() {
forward();
delay(2000);
stopMotors();
delay(1000);
backward();
delay(2000);
stopMotors();
delay(1000);
turnLeft();
delay(1500);
stopMotors();
delay(1000);
turnRight();
delay(1500);
stopMotors();
delay(3000);
}
Demonstrates Pulse Width Modulation (PWM) on pins 5 and 10 to accelerate and decelerate motors smoothly without battery surges.
/*
* Connect Robo - Satpuda STEM Lab (Day 3)
* Code 2: L298N Motor PWM Speed Ramp
*/
const int ENA = 5;
const int IN1 = 6;
const int IN2 = 7;
const int IN3 = 8;
const int IN4 = 9;
const int ENB = 10;
void setup() {
Serial.begin(9600);
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
// Set direction forward
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void loop() {
Serial.println("Accelerating motors...");
// Ramp speed from 60 (minimum spin torque) to 255 (maximum)
for (int speed = 60; speed <= 255; speed += 5) {
analogWrite(ENA, speed);
analogWrite(ENB, speed);
Serial.print("Speed: ");
Serial.println(speed);
delay(30);
}
delay(1000);
Serial.println("Decelerating motors...");
for (int speed = 255; speed >= 60; speed -= 5) {
analogWrite(ENA, speed);
analogWrite(ENB, speed);
Serial.print("Speed: ");
Serial.println(speed);
delay(30);
}
analogWrite(ENA, 0);
analogWrite(ENB, 0);
delay(2000);
}
Students can control their car directly from the Serial Monitor in Connect Robo Studio or Web Cloud IDE!
/*
* Connect Robo - Satpuda STEM Lab (Day 3 & 4)
* Code 3: PC / Serial Keyboard Controlled Robot Car
* Commands:
* 'F' or 'f' -> Move Forward
* 'B' or 'b' -> Move Backward
* 'L' or 'l' -> Turn Left
* 'R' or 'r' -> Turn Right
* 'S' or 's' -> Stop
* '1' to '5' -> Set Speed Tier (1=Slow, 5=Max)
*/
const int ENA = 5;
const int IN1 = 6;
const int IN2 = 7;
const int IN3 = 8;
const int IN4 = 9;
const int ENB = 10;
int currentSpeed = 180;
void setup() {
Serial.begin(9600);
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
analogWrite(ENA, currentSpeed);
analogWrite(ENB, currentSpeed);
Serial.println("==========================================");
Serial.println("Connect Robo: PC Keyboard Car Control Ready!");
Serial.println("Type 'F', 'B', 'L', 'R', 'S' in Serial Monitor");
Serial.println("Press keys 1 to 5 to change speed");
Serial.println("==========================================");
}
void loop() {
if (Serial.available() > 0) {
char cmd = Serial.read();
// Speed setting
if (cmd >= '1' && cmd <= '5') {
currentSpeed = map(cmd - '0', 1, 5, 100, 255);
analogWrite(ENA, currentSpeed);
analogWrite(ENB, currentSpeed);
Serial.print("Baud Speed Set To: ");
Serial.println(currentSpeed);
return;
}
switch (cmd) {
case 'F':
case 'f':
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
Serial.println("CMD: FORWARD [F]");
break;
case 'B':
case 'b':
digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
Serial.println("CMD: BACKWARD [B]");
break;
case 'L':
case 'l':
digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
Serial.println("CMD: LEFT [L]");
break;
case 'R':
case 'r':
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
Serial.println("CMD: RIGHT [R]");
break;
case 'S':
case 's':
digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
Serial.println("CMD: STOP [S]");
break;
default:
// Ignore newline / carriage return
break;
}
}
}
Combines HC-SR04 Ultrasonic Distance Sensor with L298N Motors to navigate rooms autonomously without bumping into obstacles.
/*
* Connect Robo - Satpuda STEM Lab
* Code 4: Autonomous Obstacle Avoiding Smart Car
* Pins:
* - HC-SR04: Trig -> Pin 12, Echo -> Pin 11
* - L298N: ENA=5, IN1=6, IN2=7, IN3=8, IN4=9, ENB=10
*/
const int TRIG_PIN = 12;
const int ECHO_PIN = 11;
const int ENA = 5;
const int IN1 = 6;
const int IN2 = 7;
const int IN3 = 8;
const int IN4 = 9;
const int ENB = 10;
const int SAFE_DISTANCE_CM = 20; // Stop if obstacle closer than 20cm
long readDistanceCM() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
long duration = pulseIn(ECHO_PIN, HIGH, 25000); // 25ms timeout
if (duration == 0) return 999; // No echo, path clear
return duration / 58; // Convert microseconds to cm
}
void setup() {
Serial.begin(9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
analogWrite(ENA, 170);
analogWrite(ENB, 170);
Serial.println("Obstacle Avoider Initialized!");
}
void loop() {
long distance = readDistanceCM();
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
if (distance > SAFE_DISTANCE_CM) {
// Path clear - move forward
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
} else {
// Obstacle detected! Stop, reverse slightly, turn right
Serial.println("Obstacle Alert! Backing up...");
// 1. Stop
digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
delay(200);
// 2. Reverse
digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
delay(400);
// 3. Turn Right
digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, HIGH);
delay(500);
// 4. Stop momentarily before next scan
digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
delay(150);
}
delay(50);
}
| Symptom / Problem | Probable Cause | Instant Classroom Fix |
|---|---|---|
| Arduino resets when motors start | Brownout / Voltage drop due to sharing 9V battery | Power Arduino from USB/separate 9V or keep L298N battery pack dedicated with Common GND! |
| Motor turns backward when FORWARD called | Motor terminals reversed | Simply swap the two motor wires on the green L298N screw terminal block! |
| Motors hum but don't spin | PWM value too low (insufficient starting torque) | Raise PWM from 60 to at least 150-180 in analogWrite(ENA, ...) |
| One motor runs faster than other | Gear friction or manufacturing tolerance | In software, calibrate speeds: analogWrite(ENA, 180); analogWrite(ENB, 205); |
| L298N heats up excessively | Motor stalled or supply > 12V with jumper closed | Disconnect power immediately. Ensure wheels turn freely by hand without jamming. |
When school Wi-Fi or mobile hotspot is unavailable:
1. Open Connect Robo Studio on classroom desktop PCs (works 100% offline).
2. Students can use the built-in Pinout Guide tab for instant L298N and Uno wiring diagrams.
3. Use the built-in Serial Monitor at 9600 baud to send 'F', 'B', 'L', 'R', 'S' commands.
4. Keep the pace synchronized across Class 8, Class 9, and Class 11.