Mission Montessori Logo
Mission Montessori Coding
Customize a Robot Car with Code

Customize a Robot Car with Code

Take control of a robot car and customize its behavior with code! Write Arduino programs to make it move, sense its environment, follow paths, avoid obstacles, and do whatever you can imagine.

Arduino C++ Wi-Fi Robotics

What You Can Customize with Code

Movement Patterns

Code circles, zigzags, figure-8s, or any pattern you design!

Smart Navigation

Program how it reacts to obstacles - stop, turn, or find a new path!

Line Following Logic

Customize sensitivity and speed to follow any path you create!

LED Light Shows

Program blinking, flashing, or color-changing light patterns!

🚗
đŸ“Ļ
👤

Camera Control

Code the camera to scan, follow objects, or take photos automatically!

✨
⭐

Custom Behaviors

Combine sensors and motors to create unique robot behaviors!

CODE WALKTHROUGH

Robot_Controller.ino
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
const int rightDirA = 4;
const int rightDirB = 5;
const int leftDirA = 7;
const int leftDirB = 8;
void setup() {
  pinMode(rightDirA, OUTPUT);
  pinMode(rightDirB, OUTPUT);
  pinMode(leftDirA, OUTPUT);
  pinMode(leftDirB, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  // Logic to move robot forward
  digitalWrite(leftDirA, HIGH);
  digitalWrite(rightDirA, HIGH);
}
â„šī¸ Information Panel

Understanding how your code translates to physical robot behavior.

Custom Movement Patterns:

The code controls robot movement by adjusting the speed, direction, and timing of each motor.

  • ⭕ Circles: Run one motor at a slower speed.
  • ã€°ī¸ Zigzags: Alternating directions in intervals.

HARDWARE SETUP:

âš™ī¸
Motor Driver Board

Bridges Arduino logic and high-power motors. Receives logic signals from pins defined as OUTPUT to enable motor driving capabilities.

🔄
Left Motor

Controlled via pins 7 & 8. The code variables leftDirA and leftDirB set the polarity for this motor.

🔄
Right Motor

Controlled via pins 4 & 5. The code variables rightDirA and rightDirB set the polarity for this motor.

Obstacle_Avoidance.ino
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const int trigPin = 12;
const int echoPin = 13;
const int rightDirA = 4;
const int rightDirB = 5;
const int leftDirA = 7;
const int leftDirB = 8;
const int obstacleDistance = 20;
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(rightDirA, OUTPUT);
  pinMode(rightDirB, OUTPUT);
  pinMode(leftDirA, OUTPUT);
  pinMode(leftDirB, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  long distance = getDistance();
  if (distance < obstacleDistance) {
    turnRight();
    delay(500);
  } else {
    moveForward();
  }
}
long getDistance() {
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  long duration = pulseIn(echoPin, HIGH);
  return duration * 0.034 / 2;
}
void turnRight() {
  digitalWrite(leftDirA, LOW);
  digitalWrite(leftDirB, LOW);
  digitalWrite(rightDirA, HIGH);
  digitalWrite(rightDirB, LOW);
}
â„šī¸ Information Panel

Understanding how your code translates to physical robot behavior.

Custom Obstacle Behavior:

The code uses sensor input to make decisions about robot movement. When an obstacle is detected, the robot automatically changes direction.

  • 📡 Sensor Detection: Ultrasonic sensor measures distance to objects.
  • 🔄 Automatic Response: Code decides to turn when obstacle is too close.

HARDWARE SETUP:

📡
Ultrasonic Sensor

Mounted on front of robot. Pin 12 triggers sound waves, Pin 13 receives echo. Measures distance by calculating time for sound to bounce back.

🔄
Left Motor

Stops when obstacle detected. Controlled via leftDirA and leftDirB variables (pins 7 & 8).

🔄
Right Motor

Continues spinning to turn robot away from obstacle. Controlled via rightDirA and rightDirB variables (pins 4 & 5).