Codettes Innostarter Rover – SCOPES-DF

Author

Julie Sundar

Summary

In this one-week lesson, students aged 14 and older will learn to design and build a rover from scratch, focusing on electronic circuit creation using Arduino Nano and C++ programming. The week will encompass various disciplines, including basic electronics concepts, programming for motor and sensor control, 3D design using CAD software, and 3D printing of rover components. Students will assemble their rovers by integrating the electronic circuits with the printed parts, followed by testing and troubleshooting. The lesson culminates in presentations where students demonstrate their rovers’ functionality, showcasing their hands-on learning experience in robotics and engineering.

 

4o mini

What You'll Need

Materials

  1. Arduino Nano: The main microcontroller for the rover.
  2. Motors: DC or stepper motors for movement.
  3. Wheels: Four wheels suitable for the rover design.
  4. Chassis Materials: Lightweight materials (such as acrylic, plastic, or aluminum) for the rover’s frame.
  5. Sensors: Ultrasonic or infrared sensors for obstacle detection.
  6. Battery: A suitable battery pack to power the rover (e.g., Li-ion or AA batteries).
  7. Wires and Connectors: Jumper wires for connections and connectors for easy assembly.

Tools

  1. Soldering Iron and Solder: For making secure electrical connections.
  2. Breadboard: For prototyping the electronic circuit before final assembly.
  3. Multimeter: To measure voltage, current, and resistance in circuits.
  4. 3D Printer: For printing chassis components and other parts.
  5. Computer with CAD Software: For designing the rover chassis (e.g., Tinkercad, Fusion 360).
  6. Slicing Software: To prepare 3D models for printing.

Additional Resources

  1. C++ Programming Environment: Software like the Arduino IDE for coding and uploading to the Arduino Nano.
  2. Safety Equipment: Safety goggles and gloves for protection during assembly and soldering.
  3. Documentation: Access to tutorials, datasheets, and design guides related to components and programming.

With these materials and tools, students will have everything they need to successfully design, program, and build their rovers throughout the course.

The Instructions

Lesson 1: Blinking an LED, Turning a Servo, and Using an Ultrasonic Distance sensor.

Objective: This lesson will introduce you to basic electronics and programming concepts using C++. You will learn to control an LED, a servo motor, and an ultrasonic distance sensor

Step 1: Setting Up Tinkercad and Starting a New Project.

Instructions:

  • -Open Tinkercad and sign in.
  • -Navigate to the “Circuits” section.

   

  • -Click “Circuit” to start a new project. This should lead you to your workspace.

  • -Add an Arduino board to the workspace.

  • -Add a Breadboard to the workspace.

  • -Connect the 5v to the positive(+) rail on the breadboard.

  • -Connect the GND to the negative rail (-) on the breadboard.

 

Notes:

  • -Circuits: A circuit is a path that electricity follows to power things like lights or motors.
  • -Arduino board: An Arduino board is a small computer that can control things like lights or motors using code.
  • -Breadboard: A breadboard is a tool where you can connect electronic parts together without soldering.
  • -5V: The 5V pin gives out a small amount of power to run parts like LEDs or sensors.
  • -GND :stands for Ground. It’s where the electricity returns after it has powered something.

Step 2: Blinking an LED.

Connecting the LED:

  • -Drag an LED onto the breadboard.

  • -Connect the cathode (short leg) of the LED to GND on the Arduino.

  • -Connect the anode(long bend one) to a 220Ω resistor then to digital pin 13 on the Arduino.

 

  • In the circuit workspace, click on the “Code” button located in the upper-right corner of the screen.

  • The code editor will open with block-based coding by default.
  • Switch to “Text” mode by clicking the “Blocks” dropdown menu and selecting “Text”.

 

 

 

  • A prompt will appear asking if you want to switch from blocks to text.
  • Click “Continue” to confirm.
  • Click inside the code editor and paste your code by pressing Ctrl + V (Windows) or Cmd + V (Mac).
  • After pasting the code, click “Start Simulation” to run the program and test the circuit.

 

 

Copy and paste this code into the code editor:

int ledPin = 13// Define pin 13 as the LED pin

 

void setup() {

  pinMode(ledPin, OUTPUT);  // Set the LED pin as an output pin

}

 

void loop() {

  digitalWrite(ledPin, HIGH);  // Turn the LED on

  delay(1000);  // Wait for one second

  digitalWrite(ledPin, LOW);  // Turn the LED off

  delay(1000);  // Wait for one second

}

Code explanation:

int ledPin = 13; defines the pin number for the LED.

pinMode(ledPin, OUTPUT); sets the pin as an output.

digitalWrite(ledPin, HIGH); turns the LED on.

delay(1000); pauses the program for one second.

digitalWrite(ledPin, LOW); turns the LED off.

 

Notes:

  • LED: An LED (Light Emitting Diode) is a small electronic light source that glows when electricity flows through it. It’s used in many electronic projects to indicate status or as a light source.
  • -The anode: The anode is the longer leg of an LED. It’s the positive side where the electrical current enters the LED.
  • -The cathode: The cathode is the shorter leg of an LED. It’s the negative side where the electrical current exits the LED.
  • -int: int is a type of variable in programming that stores whole numbers (like 1, 10, -3) but not fractions or decimals.
  • pinMode: pinMode is a function in Arduino programming that sets a pin on the Arduino board to either input (receiving data) or output (sending data or controlling devices).
  • -digitalWrite: digitalWrite is a function in Arduino programming that turns a pin on or off by sending a high (on) or low (off) electrical signal.
  • -variable: A variable is like a storage box in programming where you can keep data, such as numbers or text. You can change what’s in the box whenever you need to.

Step 3: Monitoring LED State with Serial Output

 Modify the code to include serial communication that tracks the LED’s state:

  • -Add Serial.begin(9600); in the setup() function:
  • -Add Serial.print(“LED State: “); and Serial.println(“ON”); in the loop()
  • -Add Serial.print(“LED State: “); and Serial.println(“OFF”); in the loop()
  • After pasting the code, click “Start Simulation” to run the program and test the circuit.

Copy and paste code into the code editotor

int ledPin = 13// Define pin 13 as the LED pin

 

void setup() {

  pinMode(ledPin, OUTPUT);  // Set the LED pin as an output

  Serial.begin(9600);       // Initialize serial communication at 9600 baud

}

 

void loop() {

  digitalWrite(ledPin, HIGH);  // Turn the LED on

  Serial.print(“LED State: “); // Print label for clarity

  Serial.println(“ON”);       // Print LED state and move to new line

  delay(1000);                 // Wait for one second

 

  digitalWrite(ledPin, LOW);   // Turn the LED off

  Serial.print(“LED State: “); // Print label for clarity

  Serial.println(“OFF”);      // Print LED state and move to new line

  delay(1000);                 // Wait for one second

}

Code explanation:

  • Serial.begin(9600);: Initializes serial communication at a baud rate of 9600 bits per second. This sets up the Arduino to send and receive data via the Serial Monitor.
  • Serial.print(“text”);: Sends the specified text to the Serial Monitor without moving to a new line. Useful for printing labels or continuous data.
  • Serial.println(“text”);: Sends the specified text to the Serial Monitor and moves to a new line. This is useful for separating lines of output and making it easier to read.

Step 4: Adding and Controlling Multiple LEDs:

-Place two more LEDs on the breadboard.

-Connect their cathodes to digital pins 12 and 11 on the Arduino.

-Connect their anodes to 220Ω resistors, then to GND on the Arduino.

-After pasting the code, click “Start Simulation” to run the program and test the circuit.

Copy and paste the code in to the code editor.

int ledPin1 = 13// First LED

int ledPin2 = 12// Second LED

int ledPin3 = 11// Third LED

 

void setup() {

  pinMode(ledPin1, OUTPUT);  // Set pin 13 as an output

  pinMode(ledPin2, OUTPUT);  // Set pin 12 as an output

  pinMode(ledPin3, OUTPUT);  // Set pin 11 as an output

  Serial.begin(9600);        // Start serial communication at 9600 baud

}

 

void loop() {

  digitalWrite(ledPin1, HIGH);  // Turn the first LED on

  digitalWrite(ledPin2, HIGH);  // Turn the second LED on

  digitalWrite(ledPin3, HIGH);  // Turn the third LED on

  Serial.println(“All LEDs ON”); // Print message to Serial Monitor

  delay(1000);  // Wait for one second

 

  digitalWrite(ledPin1, LOW);  // Turn the first LED off

  digitalWrite(ledPin2, LOW);  // Turn the second LED off

  digitalWrite(ledPin3, LOW);  // Turn the third LED off

  Serial.println(“All LEDs OFF”); // Print message to Serial Monitor

  delay(1000);  // Wait for one second

}

Code explanation:

  • -int ledPin1 = 13;, int ledPin2 = 12;, int ledPin3 = 11; define three variables representing the digital pins connected to the three LEDs.
  • -pinMode(ledPin1, OUTPUT);, pinMode(ledPin2, OUTPUT);, pinMode(ledPin3, OUTPUT); set these pins as output pins, allowing them to control the LEDs.
  • -digitalWrite(ledPin1, HIGH);, digitalWrite(ledPin2, HIGH);, digitalWrite(ledPin3, HIGH); turn on the LEDs by sending a HIGH signal to the respective pins.
  • -delay(1000); pauses the program for one second after turning the LEDs on.
  • -digitalWrite(ledPin1, LOW);, digitalWrite(ledPin2, LOW);, digitalWrite(ledPin3, LOW); turn off the LEDs by sending a LOW signal.
  • -Another delay(1000); pauses for one second before the loop repeats.
  • -Serial.begin(9600);: Starts serial communication at a speed of 9600 bits per second. This is done once in the setup() function to set up the Serial Monitor.
  • -Serial.println(“All LEDs ON”);: Sends the message “All LEDs ON” to the Serial Monitor and moves to a new line. This shows when all LEDs are turned on.
  • -Serial.println(“All LEDs OFF”);: Sends the message “All LEDs OFF” to the Serial Monitor and moves to a new line. This shows when all LEDs are turned off.

Step 5: Controlling a Servo Motor (30 minutes)

Connect the Servo:

  • Create a new circuit.
  • -Place the servo motor on the breadboard.
  • -Connect the red wire (VCC) of the servo to the 5V rail on the breadboard.
  • -Connect the black wire (GND) of the servo to the GND rail on the breadboard.
  • -Connect the yellow wire (signal) of the servo to digital pin 9 on the Arduino.

  • After pasting the code, click “Start Simulation” to run the program and test the circuit.

 

Copy and paste the code into the code editor 

int servoPin = 9// Define pin 9 for the servo motor

 

#include <Servo.h>  // Include the Servo library

 

Servo myServo;  // Create a Servo object

 

void setup() {

  myServo.attach(servoPin);  // Attach the servo to pin 9

  Serial.begin(9600);        // Initialize serial communication at 9600 baud

}

 

void loop() {

  myServo.write(0);          // Turn the servo to 0 degrees

  Serial.print(“Servo angle: “);  // Print label for clarity

  Serial.println(“0 degrees”);    // Print the current angle

  delay(1000);                // Wait for one second

 

  myServo.write(90);         // Turn the servo to 90 degrees

  Serial.print(“Servo angle: “);  // Print label for clarity

  Serial.println(“90 degrees”);   // Print the current angle

  delay(1000);                // Wait for one second

 

  myServo.write(180);        // Turn the servo to 180 degrees

  Serial.print(“Servo angle: “);  // Print label for clarity

  Serial.println(“180 degrees”);  // Print the current angle

  delay(1000);                // Wait for one second

}

 

Code explanation:

  • – servoPin = 9; defines the pin for the servo motor.
  • -Servo myServo; creates a Servo object to control the servo motor.
  • -myServo.attach(servoPin);  attaches the servo motor to the specified pin.
  • -myServo.write(0);  moves the servo to 0 degrees.
  • -myServo.write(90); moves the servo to 90 degrees.
  • -myServo.write(180); moves the servo to 180 degrees.

 

Notes:

  • Library: A collection of code that provides functions to control hardware components like a servo motor. For controlling servos, the Servo.h library is used.
  • Object: An instance of a class created from the library. For example, myServo is an object of the Servo class, allowing you to control a specific servo motor.
  • Method:.attach(pin): Connects the servo motor to a specific PWM pin on the Arduino so it can be  controlled.
  • .write(angle): Sets the position of the servo to a specified angle (e.g., 0, 90, or 180 degrees).\
  • PWM Pins: Special pins on the Arduino that produce a Pulse Width Modulation (PWM) signal. These pins are used to control the angle of the servo motor by changing the width of the pulses.

 

Step 6: Adding a Second Servo Motor 

Connect the Second Servo:

  • -Place the second servo motor on the breadboard.
  • -Connect the red wire (VCC) of the servo to the 5V rail on the breadboard
  • -Connect the black wire (GND) of the servo to the GND rail on the breadboard.
  • -Connect the yellow wire (signal) of the servo to digital pin 10 on the Arduino.
  •  paste the code, click “Start Simulation” to run the program and test the circuit.

 

Copy and paste this code into the code editor

#include <Servo.h>  // Include the Servo library

 

int servoPin1 = 9// Define pin 9 for the first servo motor

int servoPin2 = 10; // Define pin 10 for the second servo motor

 

Servo myServo1;  // Create a Servo object for the first servo motor

Servo myServo2;  // Create a Servo object for the second servo motor

 

void setup() {

  myServo1.attach(servoPin1);  // Attach the first servo to pin 9

  myServo2.attach(servoPin2);  // Attach the second servo to pin 10

  Serial.begin(9600);         // Initialize serial communication

}

 

void loop() {

  myServo1.write(0);          // Move the first servo to 0 degrees

  myServo2.write(0);          // Move the second servo to 0 degrees

  Serial.print(“Servo 1 angle: “);

  Serial.println(“0 degrees”);  // Print the angle of the first servo

  Serial.print(“Servo 2 angle: “);

  Serial.println(“0 degrees”);  // Print the angle of the second servo

  delay(1000);                // Wait for one second

 

  myServo1.write(90);         // Move the first servo to 90 degrees

  myServo2.write(90);         // Move the second servo to 90 degrees

  Serial.print(“Servo 1 angle: “);

  Serial.println(“90 degrees”); // Print the angle of the first servo

  Serial.print(“Servo 2 angle: “);

  Serial.println(“90 degrees”); // Print the angle of the second servo

  delay(1000);                // Wait for one second

 

  myServo1.write(180);        // Move the first servo to 180 degrees

  myServo2.write(180);        // Move the second servo to 180 degrees

  Serial.print(“Servo 1 angle: “);

  Serial.println(“180 degrees”); // Print the angle of the first servo

  Serial.print(“Servo 2 angle: “);

  Serial.println(“180 degrees”); // Print the angle of the second servo

  delay(1000);                // Wait for one second

}

 

Code Explanation:

  • -servoPin1 = 9;: Defines the pin for the first servo motor.
  • -servoPin2 = 10;: Defines the pin for the second servo motor.
  • -Servo myServo1;: Creates a Servo object to control the first servo motor.
  • -Servo myServo2;: Creates a Servo object to control the second servo motor.
  • -myServo1.attach(servoPin1);: Attaches the first servo motor to pin 9.
  • -myServo2.attach(servoPin2);: Attaches the second servo motor to pin 10.
  • -myServo1.write(0);: Moves the first servo to 0 degrees.
  • -myServo1.write(90);: Moves the first servo to 90 degrees.
  • -myServo1.write(180);: Moves the first servo to 180 degrees.
  • -myServo2.write(0);: Moves the second servo to 0 degrees.

Step 7: Using an Ultrasonic Distance Sensor.

 Connect the Ultrasonic Sensor:

  •  -Drag an ultrasonic distance sensor onto the breadboard.
  •  -Connect the VCC pin of the sensor to the positive rail on the breadboard.
  •  -Connect the GND pin of the sensor to the negative rail on the breadboard.
  •  -Connect the Trig pin of the sensor to digital pin 7 on the Arduino.
  • -Connect the Echo pin of the sensor to digital pin 6 on the Arduino.

 

Copy and paste the code in the code editor:

int trigPin = 7// Trig pin for sending out sound waves

int echoPin = 6// Echo pin for receiving sound waves

long duration;    // Variable to store the time it takes for the echo to return

int distance;     // Variable to store the calculated distance

 

void setup() {

  pinMode(trigPin, OUTPUT);  // Set the Trig pin as output

  pinMode(echoPin, INPUT);   // Set the Echo pin as input

  Serial.begin(9600);        // Begin serial communication for debugging

}

 

void loop() {

  digitalWrite(trigPin, LOW);  // Make sure the Trig pin is low

  delayMicroseconds(2);        // Wait for 2 microseconds

  digitalWrite(trigPin, HIGH); // Send a sound wave pulse

  delayMicroseconds(10);       // Wait for 10 microseconds

  digitalWrite(trigPin, LOW);  // Stop sending the pulse

 

  duration = pulseIn(echoPin, HIGH);  // Measure the duration of the echo

  distance = duration * 0.034 / 2;    // Calculate distance in cm

 

  Serial.print(“Distance: “);  // Print the distance to the Serial Monitor

  Serial.print(distance);

  Serial.println(” cm”);

 

  delay(500);  // Wait half a second before measuring again

}

Code explanation:

  • trigPin = 7; defines the pin for sending out sound waves.
  • echoPin = 6; defines the pin for receiving sound waves.
  • duration: stores the time it takes for the echo to return.
  • distance :stores the calculated distance based on the duration.
  • digitalWrite(trigPin, HIGH); sends a pulse from the sensor.
  • pulseIn(echoPin, HIGH); measures the time it takes for the echo to return.
  • distance = duration * 0.034 / 2; calculates the distance using the speed of sound.

 

Notes:

  • -Ultrasonic Distance Sensor: Measures how far away an object is by sending out sound waves and measuring how long it takes for them to return.
  • -Trig Pin: Sends out a pulse to trigger the sensor to start measuring distance.
  • -Echo Pin: Receives the pulse when the sound waves bounce back from the object, allowing the sensor to calculate the distance.

Step 8: Combining the Servo Motor and Ultrasonic Sensor

-Add a servo to the existing circuit.

 

-Update the existing code to control the newly added servo motor based on the distance measured by the ultrasonic sensor. The servo’s position will adjust according to the distance detected by the ultrasonic sensor.

Code:

#include <Servo.h>

 

Servo servo1;

int servoPin = 6;

 

int echoPin = 3;

int trigPin = 5;

long duration;

int distance;

 

void setup() {

  servo1.attach(servoPin);

  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

 

  Serial.begin(9600);

 

}

 

void loop() {

  // Trigger the ultrasonic sensor

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

 

  // Read the echo

  duration = pulseIn(echoPin, HIGH);

 

  // Calculate the distance

  distance = duration * 0.034 / 2;

 

  // Print the distance to the serial monitor

  Serial.print(“Distance: “);

  Serial.print(distance);

  Serial.println(” cm”);

 

  // Control the servo based on the distance

  if (distance < 20) {

    Serial.println(“Angle 90”);

    servo1.write(90);  // Move the servo to 90 degrees

    delay(1000);

  } else if (distance > 20) {

    Serial.println(“Angle 0”);

    servo1.write(0);  // Move the servo to 0 degrees

  }

 

  delay(500);  // Delay between measurements

}

 

 

Code explanation:

The servo motor now moves to different angles based on the distance measured by the ultrasonic sensor.

If the distance is less than 20 cm, the servo moves to 0 degrees.

If the distance is between 20 and 50 cm, the servo moves to 90 degrees.

If the distance is more than 50 cm, the servo moves to 180 degrees.

 

Step 9: Combining the Ultrasonic Sensor with an LED

Connect the LED:

  • Create a new circuit and connect a ultrasonic distance sensor.
  • -Place an LED on the breadboard.
  • -Connect the anode (long leg) of the LED to digital pin 13 on the Arduino.
  • -Connect the cathode (short leg) to a 220Ω resistor, then to GND on the Arduino.

Code:

int ledPin = 13;   // Pin for the LED

int trigPin = 7;   // Pin for the ultrasonic sensor’s trigger

int echoPin = 6;   // Pin for the ultrasonic sensor’s echo

 

long duration;     // Variable to store the time of the echo

int distance;      // Variable to store the calculated distance

 

void setup() {

  pinMode(ledPin, OUTPUT);   // Set the LED pin as an output

  pinMode(trigPin, OUTPUT);  // Set the trigger pin as an output

  pinMode(echoPin, INPUT);   // Set the echo pin as an input

  Serial.begin(9600);        // Initialize serial communication at 9600 baud

}

 

void loop() {

  // Send a pulse from the trigger pin

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

 

  // Measure the duration of the echo

  duration = pulseIn(echoPin, HIGH);

 

  // Calculate distance in cm

  distance = duration * 0.034 / 2;

 

  // Print distance to Serial Monitor

  Serial.print(“Distance: “);

  Serial.print(distance);

  Serial.println(” cm”);

 

  // Control the LED based on the distance

  if (distance < 20) {  // If the object is closer than 20 cm

    digitalWrite(ledPin, HIGH);  // Turn the LED on

  } else {

    digitalWrite(ledPin, LOW);   // Turn the LED off

  }

 

  delay(500);  // Wait half a second before taking another measurement

}

Code explanation:

  • -ledPin = 13;: Defines the pin for the LED.
  • -trigPin = 7;: Defines the pin for sending out sound waves from the ultrasonic sensor.
  • -echoPin = 6;: Defines the pin for receiving sound waves from the ultrasonic sensor.
  • -duration: Stores the time it takes for the echo to return.
  • -distance: Stores the calculated distance based on the duration.
  • -digitalWrite(trigPin, HIGH);: Sends a pulse from the ultrasonic sensor.
  • -pulseIn(echoPin, HIGH);: Measures the time it takes for the echo to return.
  • -distance = duration * 0.034 / 2;: Calculates the distance using the speed of sound.
  • -digitalWrite(ledPin, HIGH);: Turns the LED on when the object is closer than 20 cm.
  • -digitalWrite(ledPin, LOW);: Turns the LED off when the object is farther than 20 cm.

 

Step 10: Lesson review

  1. What is an Arduino?
  2. What is a breadboard?
  3. What is the purpose of a resistor in a circuit?
  4. What is the purpose of the delay() function in an Arduino sketch?
  5. What is a variable, and how is it used in Arduino programming?

 

 

Lesson 2: DC Motor Control

Objective :This lesson focuses on controlling a DC motor with an Arduino and an L293D motor driver in Tinkercad. It includes wiring the DC motor and motor driver to the Arduino, and writing code to control the motor's direction . The lesson demonstrates simulating the motor's operation, emphasizing basic motor control and circuit design skills.

Step 1: Setting Up the Tinkercad Workspace

 

Instructions: 

  • -Open Tinkercad and log in to create a new circuit.
  • -Navigate to the “Circuits” section.
  • -Click “Circuits” to start a new project.
  • -Add an Arduino board to the workspace.
  • -Add a breadboard to the workspace.
  • -Add an L298N Motor Driver to the workspace.
  • -Add a DC motors to the workspace.

 

 

Notes:

  • -L298N Motor Driver: A component that helps control how fast and in which direction your motors spin. It connects your Arduino to the motors and allows you to turn them on or off, or make them go forward or backward.
  • -DC Motors: These are the motors that spin when you send them electrical power. They are used to make things move, like wheels or fans.
  • -Push Button: A simple switch that you press to send a signal to the Arduino. When you press it, it can turn things on or off, like starting or stopping a motor.

 

Step 2: Connecting a DC Motor to the Arduino Using a Breadboard and Motor Driver

Place the motor driver on the breadboard:

  • Connect the motor driver’s IN1 and IN2 pins to Arduino digital pins 9 and 10.
  • Connect OUT1 and OUT2 of the motor driver to the DC motor’s terminals.

Power the motor driver and breadboard:

  • -Connect the motor driver’s VCC pin to the breadboard’s positive rail, powered by the 5V pin on the Arduino.
  • -Connect the motor driver’s GND pin to the GND rail of the breadboard, powered by the GND pin of the Arduino.
  • -Connect the motor driver’s ENA pin (used for PWM control of speed) to a PWM-capable pin ( pin 6) on the Arduino to enable motor speed control.

 

Copy and paste the code:

int motorPin1 = 9// Control pin 1 for the motor

int motorPin2 = 10; // Control pin 2 for the motor

int enablePin = 6// PWM pin for motor speed control

 

void setup() {

  pinMode(motorPin1, OUTPUT);  // Set motor control pin 1 as an output

  pinMode(motorPin2, OUTPUT);  // Set motor control pin 2 as an output

  pinMode(enablePin, OUTPUT);  // Set the enable pin as an output

}

 

void loop() {

  analogWrite(enablePin, 255);  // Set motor speed to maximum (255)

  digitalWrite(motorPin1, HIGH); // Set IN1 high

  digitalWrite(motorPin2, LOW);  // Set IN2 low

  delay(2000);  // Run the motor for 2 seconds

 

  digitalWrite(motorPin1, LOW);  // Stop the motor

  digitalWrite(motorPin2, LOW);  // Stop the motor

  delay(2000);  // Wait for 2 seconds

}

 

Code Explanation:

  • int motorPin1 = 9;: Defines pin 9 for controlling one side of the motor.
  • int motorPin2 = 10;: Defines pin 10 for controlling the other side of the motor.
  • int enablePin = 6;: Defines pin 6 for controlling the motor speed using PWM.

void setup()

  • pinMode(motorPin1, OUTPUT);: Sets pin 9 as an output.
  • pinMode(motorPin2, OUTPUT);: Sets pin 10 as an output.
  • pinMode(enablePin, OUTPUT);: Sets pin 6 as an output.

void loop()

  • analogWrite(enablePin, 255);: Sets the motor speed to maximum.
  • digitalWrite(motorPin1, HIGH);: Turns on one side of the motor.
  • digitalWrite(motorPin2, LOW);: Turns off the other side of the motor.
  • delay(2000);: Runs the motor for 2 seconds.
  • digitalWrite(motorPin1, LOW);: Stops the motor.
  • digitalWrite(motorPin2, LOW);: Ensures the motor is fully stopped.
  • delay(2000);: Waits for 2 seconds before repeating the loop

Step 3: Turning the Motor On and Off Using a Push Button

Place the push button on the breadboard:

  • -Connect one side of the button to digital pin 7 of the Arduino.
  • -Connect the other side of the button to the breadboard’s GND rail.

Add a 10k ohm pull-up resistor:

  • -Connect one side of the resistor to the push button pin connected to digital pin 7.
  • -Connect the other side of the resistor to the breadboard’s positive rail.

 

 

Copy and paste this code into the code editor:

int motorPin1 = 9// Control pin 1 for the motor

int motorPin2 = 8// Control pin 2 for the motor

int enablePin = 6// Enable pin for motor speed control

int buttonPin = 7// Button pin

 

void setup() {

  pinMode(motorPin1, OUTPUT);  // Set motor control pin 1 as an output

  pinMode(motorPin2, OUTPUT);  // Set motor control pin 2 as an output

  pinMode(enablePin, OUTPUT);  // Set enable pin as an output

  pinMode(buttonPin, INPUT_PULLUP);  // Set the button pin as an input with an internal pull-up resistor

}

 

void loop() {

  int buttonState = digitalRead(buttonPin);  // Read the button state

 

  if (buttonState == LOW) {  // If button is pressed

    digitalWrite(motorPin1, HIGH);  // Set IN1 high to turn the motor on

    digitalWrite(motorPin2, LOW);   // Set IN2 low

    analogWrite(enablePin, 255);    // Set the motor speed to maximum (255)

  } else {

    digitalWrite(motorPin1, LOW);  // Set both IN1 and IN2 low to stop the motor

    digitalWrite(motorPin2, LOW);

    analogWrite(enablePin, 0);     // Turn off the motor (speed 0)

  }

}

 

Code Explanation:

  • int motorPin1 = 9;: Pin 9 controls one side of the motor.
  • int motorPin2 = 8;: Pin 8 controls the other side of the motor.
  • int buttonPin = 7;: Pin 7 is used for the push button.
  • int enablePin = 6;: Defines pin 6 for controlling the motor speed using PWM.
  • -void setup() { … }:

pinMode(motorPin1, OUTPUT);: Sets pin 9 as an output to control the motor.

            pinMode(motorPin2, OUTPUT);: Sets pin 8 as an output to control the motor.

            pinMode(buttonPin, INPUT_PULLUP);: Sets pin 7 as an input with a pull-up resistor   

           (button press reads LOW).

  • – void loop() { … }:

             int buttonState = digitalRead(buttonPin);: Reads whether the button is pressed (LOW) 

            or not (HIGH).

            if (buttonState == LOW) { … }: If the button is pressed:

            digitalWrite(motorPin1, HIGH);: Turns on the motor by setting pin 9 high. 

            digitalWrite(motorPin2, LOW);: Ensures pin 8 is low, so the motor runs in one direction.

            else { … }: If the button is not pressed:

            digitalWrite(motorPin1, LOW);: Stops the motor by setting pin 9 low.

           digitalWrite(motorPin2, LOW);: Ensures pin 8 is also low, stopping the motor.

 

Step 4: Adding a Second Motor.

Add the second motor to the breadboard:

Connect the second motor’s terminals to the motor driver’s OUT3 and OUT4.

Connect motor driver inputs to Arduino:

-Connect IN3 and IN4 of the motor driver to Arduino pins 11 and 12.

The second motor will share the power lines already connected to the 5V and GND rails of the breadboard.

 Copy and paste the code into the code editor:

int motorPin1 = 9// Control pin 1 for the first motor

int motorPin2 = 8// Control pin 2 for the first motor

int motorPin3 = 11; // Control pin 1 for the second motor

int motorPin4 = 12; // Control pin 2 for the second motor

int enablePin1 = 6; // Enable pin for the first motor

int enablePin2 = 3; // Enable pin for the second motor

int buttonPin = 7// Button pin

 

void setup() {

  pinMode(motorPin1, OUTPUT);  // Set motor control pin 1 for the first motor as an output

  pinMode(motorPin2, OUTPUT);  // Set motor control pin 2 for the first motor as an output

  pinMode(motorPin3, OUTPUT);  // Set motor control pin 1 for the second motor as an output

  pinMode(motorPin4, OUTPUT);  // Set motor control pin 2 for the second motor as an output

  pinMode(enablePin1, OUTPUT); // Set enable pin for the first motor as an output

  pinMode(enablePin2, OUTPUT); // Set enable pin for the second motor as an output

  pinMode(buttonPin, INPUT_PULLUP);  // Set the button pin as an input with an internal pull-up resistor

}

 

void loop() {

  int buttonState = digitalRead(buttonPin);  // Read the button state

 

  if (buttonState == LOW) {  // If button is pressed

    // First motor control

    digitalWrite(motorPin1, HIGH);  // Set IN1 high to turn the first motor on

    digitalWrite(motorPin2, LOW);   // Set IN2 low for the first motor

    analogWrite(enablePin1, 255);   // Set the first motor speed to maximum

 

    // Second motor control

    digitalWrite(motorPin3, HIGH);  // Set IN3 high to turn the second motor on

    digitalWrite(motorPin4, LOW);   // Set IN4 low for the second motor

    analogWrite(enablePin2, 255);   // Set the second motor speed to maximum

  } else {

    // Stop both motors

    digitalWrite(motorPin1, LOW);   // Set both IN1 and IN2 low to stop the first motor

    digitalWrite(motorPin2, LOW);

    analogWrite(enablePin1, 0);     // Stop the first motor

 

    digitalWrite(motorPin3, LOW);   // Set both IN3 and IN4 low to stop the second motor

    digitalWrite(motorPin4, LOW);

    analogWrite(enablePin2, 0);     // Stop the second motor

  }

}

 

Code explanation:

  • motorPin1, motorPin2: Control the first motor using pins 9 and 8.
  • motorPin3, motorPin4: Control the second motor using pins 6 and 5.
  • buttonPin: Pin 7 is used to read the button state.
  • -void setup():

               pinMode(): Configures motor pins as outputs and the button pin as an input with an

               internal pull-up resistor

  • -void loop():

              buttonState: Reads the button state.

              If the button is pressed (LOW), both motors turn on (motorPin1 and motorPin3 set  

              HIGH).

             If not pressed, both motors stop (all motor pins set LOW).

 

Step 5: Open a New Circuit in Tinkercad and Connecting Two DC Motors to Arduino Using a Motor Driver on.

  • -Click “Circuits” in the Tinkercad dashboard.
  • -Click “Create New Circuit” to start a new project.
  • -Add an Arduino Uno to the workspace.
  • -Add an L298N motor driver to the workspace.
  • -Add two DC motors to the workspace.
  • -Add a breadboard to the workspace.
  • -Connect the Arduino’s 5V pin to the positive rail of the breadboard.
  • -Connect the GND pin of the Arduino to the negative rail of the breadboard.
  • -Connect ENA and ENB pins on the motor driver to PWM pins on the Arduino (pins 9 and 10).
  • -Connect IN1, IN2, IN3, and IN4 on the motor driver to digital pins (pins 8, 7, 6, and 5).
  • -Connect the DC motors to the motor driver’s OUT1, OUT2 (motor 1) and OUT3, OUT4 (motor 2).
  • -Attach the power supply to the motor driver to power the motors.

 

 

 

Step 6: Creating Start and Stop Functions for Controlling DC Motors

  • -In the Tinkercad code editor, switch to the “Blocks + Text” view.
  • -Click “Code” to open the code editor if it’s not already visible.
  • -Delete any existing code to start with a blank slate.
  • -In the code editor, write two functions: one to start the motors and another to stop them.

Code:

// MOTOR 1

int motor1enA = 9// PWM Speed Control (ENA connected to pin 9)

int motor1in1 = 8// Direction Control (IN1 connected to pin 8)

int motor1in2 = 7// Direction Control (IN2 connected to pin 7)

 

// MOTOR 2

int motor2enB = 10; // PWM Speed Control (ENB connected to pin 10)

int motor2in3 = 6// Direction Control (IN3 connected to pin 6)

int motor2in4 = 5// Direction Control (IN4 connected to pin 5)

 

// Serial Communication

int state;

 

void setup() {

  // Start serial communication

  Serial.begin(9600);

 

  // MOTOR 1 OUTPUTS

  pinMode(motor1enA, OUTPUT);

  pinMode(motor1in1, OUTPUT);

  pinMode(motor1in2, OUTPUT);

 

  // MOTOR 2 OUTPUTS

  pinMode(motor2enB, OUTPUT);

  pinMode(motor2in3, OUTPUT);

  pinMode(motor2in4, OUTPUT);

 

  // Set initial motor speed

  analogWrite(motor1enA, 100); // Set speed (0-255)

  analogWrite(motor2enB, 100); // Set speed (0-255)

}

 

// Function to start both motors (forward direction)

void startMotors() {

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

// Function to stop both motors

void stopMotors() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

void loop() {

  // Serial control for starting and stopping motors

  if (Serial.available() > 0) {

    state = Serial.read();

    if (state == ‘S’) {

      Serial.println(“Stop Motors”);

      stopMotors();

    } else if (state == ‘F’) {

      Serial.println(“Start Motors”);

      startMotors();

    }

  }

}

 

Explanation:

Motor 1:

  • motor1enA = 9: Controls the speed of Motor 1 using PWM (Pulse Width Modulation). The PWM value is set with analogWrite(), where 0 is off and 255 is the maximum speed.
  • motor1in1 = 8, motor1in2 = 7: These control the direction of Motor 1. By setting one pin HIGH and the other LOW, the motor moves forward or backward.

 

Motor 2:

  • motor2enB = 10: Controls the speed of Motor 2 using PWM, similar to Motor 1.

            motor2in3 = 6, motor2in4 = 5: These control the direction of Motor 2 in the same way  

            as Motor 1.

 

  • -void setup():Serial Communication: Serial.begin(9600) starts the serial communication at 9600 baud rate. This allows the Arduino to receive commands (start/stop) from the Serial Monitor.
  • -Motor Outputs:pinMode() is used to define the motor pins as outputs so that the Arduino can control them.
  • -Set Speed: analogWrite(motor1enA, 100) and analogWrite(motor2enB, 100) set the initial speed for both motors at around 40% (since 100/255 ≈ 40%)..

Motor Control Functions:

  • startMotors(): Moves both motors forward by setting motor1in1 and motor2in3 to HIGH and motor1in2 and motor2in4 to LOW.
  • stopMotors(): Stops both motors by setting all control pins to LOW, which effectively stops current flow to the motors.

 

Void loop() :

Serial.available() > 0: Checks if there’s data in the serial buffer (i.e., a character has been sent from the Serial Monitor).

Serial.read(): Reads the incoming data and stores it in the state variable.

If the received character is ‘S’, the motors stop, and the message “Stop Motors” is printed.

If the received character is ‘F’, the motors start moving forward, and the message “Start Motors” is printed.

 

Step 7: Open Serial Monitor and Control the DC Motor on Tinkercad.

  • -Run the Simulation in Tinkercad
  • After building your circuit in Tinkercad Click the green “Start Simulation” button to begin running the project.
  • -Open the Serial Monitor:While the simulation is running, click on the “Code” button in the top-right corner of the workspace.
  • In the dropdown, choose “Serial Monitor”. This will open a terminal window where you can send and receive serial data.

  • -Control the DC Motors via Serial Monitor
  • In the Serial Monitor, you can type characters to control the motors:
  • Type F (for “Forward”) and press Enter: The motors will start moving forward, as defined by the startMotors() function.
  • Type S (for “Stop”) and press Enter: The motors will stop, as defined by the stopMotors() function.

 

   

Step 8: Expanding Motor Control Functions.

  • -Add additional functions to control motor movements in various directions (e.g., forward, backward, left, right).
  • -Implement functionality to adjust motor speed and direction based on specific commands or conditions.
  • -Update the code to handle new commands for enhanced motor control.

 

// MOTOR 1

int motor1enA = 9// PWM Speed Control (ENA connected to pin 9)

int motor1in1 = 8// Direction Control (IN1 connected to pin 8)

int motor1in2 = 7// Direction Control (IN2 connected to pin 7)

 

// MOTOR 2

int motor2enB = 10; // PWM Speed Control (ENB connected to pin 10)

int motor2in3 = 6// Direction Control (IN3 connected to pin 6)

int motor2in4 = 5// Direction Control (IN4 connected to pin 5)

 

// Serial Communication

int state;

 

void setup() {

  // Start serial communication

  Serial.begin(9600);

 

  // MOTOR 1 OUTPUTS

  pinMode(motor1enA, OUTPUT);

  pinMode(motor1in1, OUTPUT);

  pinMode(motor1in2, OUTPUT);

 

  // MOTOR 2 OUTPUTS

  pinMode(motor2enB, OUTPUT);

  pinMode(motor2in3, OUTPUT);

  pinMode(motor2in4, OUTPUT);

}

 

// Function to set motor speed and enable them

void startMotors() {

  // Set motor speeds (range: 0 – 255)

  analogWrite(motor1enA, 100); // Motor 1 speed

  analogWrite(motor2enB, 100); // Motor 2 speed

  Serial.println(“Motors started”);

}

 

// Function to move forward

void forward() {

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

// Function to move backward

void backward() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, HIGH);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, HIGH);

}

 

// Function to turn left (by rotating only Motor 1)

void left() {

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

// Function to turn right (by rotating only Motor 2)

void right() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

// Function to stop both motors

void stopM() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

void loop() {

  // Check if there is serial input

  if (Serial.available() > 0) {

    state = Serial.read();  // Read the input character

 

    // Motor control based on serial input

    if (state == ‘T’) {

      Serial.println(“Start Motors”);

      startMotors();

    } else if (state == ‘F’) {

      Serial.println(“Go Forward”);

      forward();

    } else if (state == ‘B’) {

      Serial.println(“Go Backward”);

      backward();

    } else if (state == ‘L’) {

      Serial.println(“Go Left”);

      left();

    } else if (state == ‘R’) {

      Serial.println(“Go Right”);

      right();

    } else if (state == ‘S’) {

      Serial.println(“Stop”);

      stopM();

    }

  }

}

Step 9: Controlling Motors Using Tinkercad Serial Monitor

Open the Serial Monitor: In your Tinkercad circuit, click on the “Start Simulation” button. Then, click on the “Serial Monitor” button (a small icon resembling a magnifying glass or monitor) at the top right of the simulation window.

Send Commands: Type one of the following commands in the input field and press Enter:

‘T’: Start the motors at the initial speed.

‘F’: Move the motors forward.

‘B’: Move the motors backward.

‘L’: Turn left by rotating Motor 1.

‘R’: Turn right by rotating Motor 2.

‘S’: Stop both motors.

 

Step 10: lesson review

 

  1. What is the function of the L298N motor driver in this project?
  2. Explain the purpose of the enable pin (ENA) on the motor driver.
  3. What does the LOW state represent when controlling a motor pin in the Arduino code?
  4. What will happen if the ENA pin is not connected to a PWM pin on the Arduino?
  5. What is the purpose of the OUT1 and OUT2 pin?

 

Lesson 3:From Simulation to Reality: Building Tinkercad Circuits

Objective:In this lesson, learners will transition from virtual circuit design to real-world implementation by building and testing circuits previously designed in Tinkercad. This will involve assembling components on a breadboard, wiring connections, and troubleshooting to ensure correct functionality in a physical environment. The lesson emphasizes applying theoretical knowledge to practical tasks and highlights the importance of practical testing in electronics.

Step 1: Setting Up the Arduino IDE and Starting a New Project .

  • Download  and Install Arduino IDE if you don’t have it already. 
  • Open Arduino IDE
  • Launch the Arduino IDE on your computer

Step 2: Blinking an LED (30 minutes)

Connect the LED

  • Place an LED on a breadboard.
  • the anode (long leg) of the LED to digital pin 13 on the Arduino.
  • Connect the cathode (short leg) to a 220Ω resistor, then to GND on the Arduino.

 

Copy and paste the following code into the Arduino IDE:

 

ledPin = 13// Define pin 13 as the LED pin

 

void setup() {

  pinMode(ledPin, OUTPUT);  // Set the LED pin as an output pin

  Serial.begin(9600);      // Initialize serial communication at 9600 baud rate

}

 

void loop() {

  digitalWrite(ledPin, HIGH);  // Turn the LED on

  Serial.println(“LED is ON”); // Print message to serial monitor

  delay(1000);  // Wait for one second

 

  digitalWrite(ledPin, LOW);   // Turn the LED off

  Serial.println(“LED is OFF”); // Print message to serial monitor

  delay(1000);  // Wait for one second

}

Click on the upload button in the Arduino IDE to upload the code to your Arduino board.

Observe the LED blinking on and off.

 

 

Step 3: Adding and Controlling Multiple LEDs (30 minutes)

Connect Additional LEDs

  • Place two more LEDs on the breadboard.
  • Connect their anodes to digital pins 12 and 11 on the Arduino.
  • Connect their cathodes to 220Ω resistors, then to GND on the Arduino.

 

Copy and paste the following code into the Arduino IDE:

 

int ledPin1 = 13// First LED

int ledPin2 = 12// Second LED

int ledPin3 = 11// Third LED

 

void setup() {

  pinMode(ledPin1, OUTPUT);  // Set pin 13 as an output

  pinMode(ledPin2, OUTPUT);  // Set pin 12 as an output

  pinMode(ledPin3, OUTPUT);  // Set pin 11 as an output

 

  Serial.begin(9600);  // Initialize serial communication at 9600 baud rate

}

 

void loop() {

  digitalWrite(ledPin1, HIGH);  // Turn the first LED on

  digitalWrite(ledPin2, HIGH);  // Turn the second LED on

  digitalWrite(ledPin3, HIGH);  // Turn the third LED on

  Serial.println(“All LEDs are ON”);  // Print message to serial monitor

  delay(1000);  // Wait for one second

 

  digitalWrite(ledPin1, LOW);  // Turn the first LED off

  digitalWrite(ledPin2, LOW);  // Turn the second LED off

  digitalWrite(ledPin3, LOW);  // Turn the third LED off

  Serial.println(“All LEDs are OFF”);  // Print message to serial monitor

  delay(1000);  // Wait for one second

}

 

Click on the upload button in the Arduino IDE to upload the code.

Observe the three LEDs blinking on and off together.

 

Step 4: Controlling a Servo Motor.

Connect the Servo:

  • -add a servo motor onto the breadboard.
  • -Connect the red wire (VCC) of the servo to the 5V pin on the Arduino.
  • -Connect the black wire (GND) of the servo to the GND pin on the Arduino.
  • -Connect the yellow wire (signal) of the servo to digital pin 9 on the Arduino.

 

 

int servoPin = 9// Define pin 9 for the servo motor

 

#include <Servo.h>  // Include the Servo library

 

Servo myServo;  // Create a Servo object

 

void setup() {

  myServo.attach(servoPin);  // Attach the servo to pin 9

  Serial.begin(9600);        // Initialize serial communication at 9600 baud

}

 

void loop() {

  myServo.write(0);          // Turn the servo to 0 degrees

  Serial.print(“Servo angle: “);  // Print label for clarity

  Serial.println(“0 degrees”);    // Print the current angle

  delay(1000);                // Wait for one second

 

  myServo.write(90);         // Turn the servo to 90 degrees

  Serial.print(“Servo angle: “);  // Print label for clarity

  Serial.println(“90 degrees”);   // Print the current angle

  delay(1000);                // Wait for one second

 

  myServo.write(180);        // Turn the servo to 180 degrees

  Serial.print(“Servo angle: “);  // Print label for clarity

  Serial.println(“180 degrees”);  // Print the current angle

  delay(1000);                // Wait for one second

}

Step 5: Adding a Second Servo Motor 

Connect the Second Servo:

  • -Place a second servo motor on the breadboard.
  • -Connect the red wire (VCC) of the servo to the 5V rail on the breadboard.
  • -Connect the black wire (GND) of the servo to the GND rail on the breadboard.
  • -Connect the yellow wire (signal) of the servo to digital pin 10 on the Arduino.

 

#include <Servo.h>  // Include the Servo library

 

int servoPin1 = 9// Define pin 9 for the first servo motor

int servoPin2 = 10; // Define pin 10 for the second servo motor

 

Servo myServo1;  // Create a Servo object for the first servo motor

Servo myServo2;  // Create a Servo object for the second servo motor

 

void setup() {

  myServo1.attach(servoPin1);  // Attach the first servo to pin 9

  myServo2.attach(servoPin2);  // Attach the second servo to pin 10

  Serial.begin(9600);         // Initialize serial communication

}

 

void loop() {

  myServo1.write(0);          // Move the first servo to 0 degrees

  myServo2.write(0);          // Move the second servo to 0 degrees

  Serial.print(“Servo 1 angle: “);

  Serial.println(“0 degrees”);  // Print the angle of the first servo

  Serial.print(“Servo 2 angle: “);

  Serial.println(“0 degrees”);  // Print the angle of the second servo

  delay(1000);                // Wait for one second

 

  myServo1.write(90);         // Move the first servo to 90 degrees

  myServo2.write(90);         // Move the second servo to 90 degrees

  Serial.print(“Servo 1 angle: “);

  Serial.println(“90 degrees”); // Print the angle of the first servo

  Serial.print(“Servo 2 angle: “);

  Serial.println(“90 degrees”); // Print the angle of the second servo

  delay(1000);                // Wait for one second

 

  myServo1.write(180);        // Move the first servo to 180 degrees

  myServo2.write(180);        // Move the second servo to 180 degrees

  Serial.print(“Servo 1 angle: “);

  Serial.println(“180 degrees”); // Print the angle of the first servo

  Serial.print(“Servo 2 angle: “);

  Serial.println(“180 degrees”); // Print the angle of the second servo

  delay(1000);                // Wait for one second

}

 

 

 

Step 6: Using an Ultrasonic Distance Sensor.

 Connect the Ultrasonic Sensor:

  •  -Take an an ultrasonic distance sensor
  • -Connect the VCC pin of the sensor to the 5V pin on the Arduino.
  • -Connect the GND pin of the sensor to the GND pin on the Arduino.
  • -Connect the Trig pin of the sensor to digital pin 7 on the Arduino
  • -Connect the Echo pin of the sensor to digital pin 6 on the Arduino.

Code:

int trigPin = 7// Trig pin for sending out sound waves

int echoPin = 6// Echo pin for receiving sound waves

long duration;    // Variable to store the time it takes for the echo to return

int distance;     // Variable to store the calculated distance

 

void setup() {

  pinMode(trigPin, OUTPUT);  // Set the Trig pin as output

  pinMode(echoPin, INPUT);   // Set the Echo pin as input

  Serial.begin(9600);        // Begin serial communication for debugging

}

 

void loop() {

  digitalWrite(trigPin, LOW);  // Make sure the Trig pin is low

  delayMicroseconds(2);        // Wait for 2 microseconds

  digitalWrite(trigPin, HIGH); // Send a sound wave pulse

  delayMicroseconds(10);       // Wait for 10 microseconds

  digitalWrite(trigPin, LOW);  // Stop sending the pulse

 

  duration = pulseIn(echoPin, HIGH);  // Measure the duration of the echo

  distance = duration * 0.034 / 2;    // Calculate distance in cm

 

  Serial.print(“Distance: “);  // Print the distance to the Serial Monitor

  Serial.print(distance);

  Serial.println(” cm”);

 

  delay(500);  // Wait half a second before measuring again

}

 

Step 7: Combining the Servo Motor and Ultrasonic Sensor

-Add a servo to the existing circuit.

 

-Update the existing code to control the newly added servo motor based on the distance measured by the ultrasonic sensor. The servo’s position will adjust according to the distance detected by the ultrasonic sensor.

Code:

int servoPin = 9;

int trigPin = 7;

int echoPin = 6;

long duration;

int distance;

 

#include <Servo.h>

Servo myServo;

 

void setup() {

  myServo.attach(servoPin);

  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

  Serial.begin(9600);

}

 

void loop() {

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

 

  duration = pulseIn(echoPin, HIGH);

  distance = duration * 0.034 / 2;

 

  Serial.print(“Distance: “);

  Serial.print(distance);

  Serial.println(” cm”);

 

  if (distance < 20) {  // If an object is closer than 20 cm

    myServo.write(0);   // Move the servo to 0 degrees

  } else if (distance < 50) {  // If the object is between 20 and 50 cm

    myServo.write(90);  // Move the servo to 90 degrees

  } else {

    myServo.write(180); // Move the servo to 180 degrees

  }

 

  delay(500);  // Wait before taking another measurement

}

 

 

Step 8: Combining the Ultrasonic Sensor with an LED

Connect the LED:

  • -Place an LED on the breadboard.
  • -Connect the anode (long leg) of the LED to digital pin 13 on the Arduino.
  • -Connect the cathode (short leg) to a 220Ω resistor, then to GND on the Arduino.

 

Code:

 

int ledPin = 13;   // Pin for the LED

int trigPin = 7;   // Pin for the ultrasonic sensor’s trigger

int echoPin = 6;   // Pin for the ultrasonic sensor’s echo

 

long duration;     // Variable to store the time of the echo

int distance;      // Variable to store the calculated distance

 

void setup() {

  pinMode(ledPin, OUTPUT);   // Set the LED pin as an output

  pinMode(trigPin, OUTPUT);  // Set the trigger pin as an output

  pinMode(echoPin, INPUT);   // Set the echo pin as an input

  Serial.begin(9600);        // Initialize serial communication at 9600 baud

}

 

void loop() {

  // Send a pulse from the trigger pin

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

 

  // Measure the duration of the echo

  duration = pulseIn(echoPin, HIGH);

 

  // Calculate distance in cm

  distance = duration * 0.034 / 2;

 

  // Print distance to Serial Monitor

  Serial.print(“Distance: “);

  Serial.print(distance);

  Serial.println(” cm”);

 

  // Control the LED based on the distance

  if (distance < 20) {  // If the object is closer than 20 cm

    digitalWrite(ledPin, HIGH);  // Turn the LED on

  } else {

    digitalWrite(ledPin, LOW);   // Turn the LED off

  }

 

  delay(500);  // Wait half a second before taking another measurement

}

 

Step 9: Connecting a DC Motor to the Arduino Using a Breadboard and Motor Driver

 

Place the motor driver on the breadboard:

  •  -Connect the motor driver’s IN1 and IN2 pins to Arduino digital pins 9 and 10.
  • -Connect OUT1 and OUT2 of the motor driver to the DC motor’s terminals.

Power the motor driver and breadboard:

  • -Connect the motor driver’s VCC pin to the breadboard’s positive rail, powered by the 5V pin on the Arduino.
  • -Connect the motor driver’s GND pin to the GND rail of the breadboard, powered by the GND pin of the Arduino.
  • -Connect the motor driver’s ENA pin (used for PWM control of speed) to a PWM-capable pin (pin 6) on the Arduino to enable motor speed control.

Code:

int motorPin1 = 9// Control pin 1 for the motor

int motorPin2 = 10; // Control pin 2 for the motor

int enablePin = 6// PWM pin for motor speed control

 

void setup() {

  pinMode(motorPin1, OUTPUT);  // Set motor control pin 1 as an output

  pinMode(motorPin2, OUTPUT);  // Set motor control pin 2 as an output

  pinMode(enablePin, OUTPUT);  // Set the enable pin as an output

}

 

void loop() {

  analogWrite(enablePin, 255);  // Set motor speed to maximum (255)

  digitalWrite(motorPin1, HIGH); // Set IN1 high

  digitalWrite(motorPin2, LOW);  // Set IN2 low

  delay(2000);  // Run the motor for 2 seconds

 

  digitalWrite(motorPin1, LOW);  // Stop the motor

  digitalWrite(motorPin2, LOW);  // Stop the motor

  delay(2000);  // Wait for 2 seconds

}

 

Step 10: Turning the Motor On and Off Using a Push Button

Place the push button on the breadboard:

  • -Connect one side of the button to digital pin 7 of the Arduino.
  • -Connect the other side of the button to the breadboard’s GND rail.

Add a 10k ohm pull-up resistor:

  • -Connect one side of the resistor to the push button pin connected to digital pin 7.
  • -Connect the other side of the resistor to the breadboard’s 5V rail.

code:

int motorPin1 = 9// Control pin 1 for the motor

int motorPin2 = 8// Control pin 2 for the motor

int enablePin = 6// Enable pin for motor speed control

int buttonPin = 7// Button pin

 

void setup() {

  pinMode(motorPin1, OUTPUT);  // Set motor control pin 1 as an output

  pinMode(motorPin2, OUTPUT);  // Set motor control pin 2 as an output

  pinMode(enablePin, OUTPUT);  // Set enable pin as an output

  pinMode(buttonPin, INPUT_PULLUP);  // Set the button pin as an input with an internal pull-up resistor

}

 

void loop() {

  int buttonState = digitalRead(buttonPin);  // Read the button state

 

  if (buttonState == LOW) {  // If button is pressed

    digitalWrite(motorPin1, HIGH);  // Set IN1 high to turn the motor on

    digitalWrite(motorPin2, LOW);   // Set IN2 low

    analogWrite(enablePin, 255);    // Set the motor speed to maximum (255)

  } else {

    digitalWrite(motorPin1, LOW);  // Set both IN1 and IN2 low to stop the motor

    digitalWrite(motorPin2, LOW);

    analogWrite(enablePin, 0);     // Turn off the motor (speed 0)

  }

}

 

 

Step 11: Adding a Second Motor.

Add the second motor to the breadboard:

  • -Connect the second motor’s terminals to the motor driver’s OUT3 and OUT4.

Connect motor driver inputs to Arduino:

  • -Connect IN3 and IN4 of the motor driver to Arduino pins 11 and 12.
  • The second motor will share the power lines already connected to the 5V and GND rails of the breadboard.

 code:

int motorPin1 = 9// Control pin 1 for the first motor

int motorPin2 = 8// Control pin 2 for the first motor

int motorPin3 = 11; // Control pin 1 for the second motor

int motorPin4 = 12; // Control pin 2 for the second motor

int enablePin1 = 6; // Enable pin for the first motor

int enablePin2 = 3; // Enable pin for the second motor

int buttonPin = 7// Button pin

 

void setup() {

  pinMode(motorPin1, OUTPUT);  // Set motor control pin 1 for the first motor as an output

  pinMode(motorPin2, OUTPUT);  // Set motor control pin 2 for the first motor as an output

  pinMode(motorPin3, OUTPUT);  // Set motor control pin 1 for the second motor as an output

  pinMode(motorPin4, OUTPUT);  // Set motor control pin 2 for the second motor as an output

  pinMode(enablePin1, OUTPUT); // Set enable pin for the first motor as an output

  pinMode(enablePin2, OUTPUT); // Set enable pin for the second motor as an output

  pinMode(buttonPin, INPUT_PULLUP);  // Set the button pin as an input with an internal pull-up resistor

}

 

void loop() {

  int buttonState = digitalRead(buttonPin);  // Read the button state

 

  if (buttonState == LOW) {  // If button is pressed

    // First motor control

    digitalWrite(motorPin1, HIGH);  // Set IN1 high to turn the first motor on

    digitalWrite(motorPin2, LOW);   // Set IN2 low for the first motor

    analogWrite(enablePin1, 255);   // Set the first motor speed to maximum

 

    // Second motor control

    digitalWrite(motorPin3, HIGH);  // Set IN3 high to turn the second motor on

    digitalWrite(motorPin4, LOW);   // Set IN4 low for the second motor

    analogWrite(enablePin2, 255);   // Set the second motor speed to maximum

  } else {

    // Stop both motors

    digitalWrite(motorPin1, LOW);   // Set both IN1 and IN2 low to stop the first motor

    digitalWrite(motorPin2, LOW);

    analogWrite(enablePin1, 0);     // Stop the first motor

 

    digitalWrite(motorPin3, LOW);   // Set both IN3 and IN4 low to stop the second motor

    digitalWrite(motorPin4, LOW);

    analogWrite(enablePin2, 0);     // Stop the second motor

  }

}

 

 

Step 12: Adding functions to control DC start and stop DC motor

// MOTOR 1

int motor1enA = 9// PWM Speed Control (ENA connected to pin 9)

int motor1in1 = 8// Direction Control (IN1 connected to pin 8)

int motor1in2 = 7// Direction Control (IN2 connected to pin 7)

 

// MOTOR 2

int motor2enB = 10; // PWM Speed Control (ENB connected to pin 10)

int motor2in3 = 6// Direction Control (IN3 connected to pin 6)

int motor2in4 = 5// Direction Control (IN4 connected to pin 5)

 

// Serial Communication

int state;

 

void setup() {

  // Start serial communication

  Serial.begin(9600);

 

  // MOTOR 1 OUTPUTS

  pinMode(motor1enA, OUTPUT);

  pinMode(motor1in1, OUTPUT);

  pinMode(motor1in2, OUTPUT);

 

  // MOTOR 2 OUTPUTS

  pinMode(motor2enB, OUTPUT);

  pinMode(motor2in3, OUTPUT);

  pinMode(motor2in4, OUTPUT);

 

  // Set initial motor speed

  analogWrite(motor1enA, 100); // Set speed (0-255)

  analogWrite(motor2enB, 100); // Set speed (0-255)

}

 

// Function to start both motors (forward direction)

void startMotors() {

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

// Function to stop both motors

void stopMotors() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

void loop() {

  // Serial control for starting and stopping motors

  if (Serial.available() > 0) {

    state = Serial.read();

    if (state == ‘S’) {

      Serial.println(“Stop Motors”);

      stopMotors();

    } else if (state == ‘F’) {

      Serial.println(“Start Motors”);

      startMotors();

    }

  }

}

 

Step 13: Using serial monitor.

 -Open the Serial Monitor:

Click on the Serial Monitor button (magnifying glass icon) located in the top right corner of the Arduino IDE, or go to Tools > Serial Monitor.

-Control the DC Motors via Serial Monitor

 In the Serial Monitor, you can type characters to control the motors:

Type F (for “Forward”) and press Enter: The motors will start moving forward, as defined by the startMotors() function.

Type S (for “Stop”) and press Enter: The motors will stop, as defined by the stopMotors() function.

 

Step 14 : Adding more functions.

-Update the code to handle new commands for enhanced motor control.

// MOTOR 1

int motor1enA = 9// PWM Speed Control (ENA connected to pin 9)

int motor1in1 = 8// Direction Control (IN1 connected to pin 8)

int motor1in2 = 7// Direction Control (IN2 connected to pin 7)

 

// MOTOR 2

int motor2enB = 10; // PWM Speed Control (ENB connected to pin 10)

int motor2in3 = 6// Direction Control (IN3 connected to pin 6)

int motor2in4 = 5// Direction Control (IN4 connected to pin 5)

 

// Serial Communication

int state;

 

void setup() {

  // Start serial communication

  Serial.begin(9600);

 

  // MOTOR 1 OUTPUTS

  pinMode(motor1enA, OUTPUT);

  pinMode(motor1in1, OUTPUT);

  pinMode(motor1in2, OUTPUT);

 

  // MOTOR 2 OUTPUTS

  pinMode(motor2enB, OUTPUT);

  pinMode(motor2in3, OUTPUT);

  pinMode(motor2in4, OUTPUT);

}

 

// Function to set motor speed and enable them

void startMotors() {

  // Set motor speeds (range: 0 – 255)

  analogWrite(motor1enA, 100); // Motor 1 speed

  analogWrite(motor2enB, 100); // Motor 2 speed

  Serial.println(“Motors started”);

}

 

// Function to move forward

void forward() {

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

// Function to move backward

void backward() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, HIGH);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, HIGH);

}

 

// Function to turn left (by rotating only Motor 1)

void left() {

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

// Function to turn right (by rotating only Motor 2)

void right() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

// Function to stop both motors

void stopM() {

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

void loop() {

  // Check if there is serial input

  if (Serial.available() > 0) {

    state = Serial.read();  // Read the input character

 

    // Motor control based on serial input

    if (state == ‘T’) {

      Serial.println(“Start Motors”);

      startMotors();

    } else if (state == ‘F’) {

      Serial.println(“Go Forward”);

      forward();

    } else if (state == ‘B’) {

      Serial.println(“Go Backward”);

      backward();

    } else if (state == ‘L’) {

      Serial.println(“Go Left”);

      left();

    } else if (state == ‘R’) {

      Serial.println(“Go Right”);

      right();

    } else if (state == ‘S’) {

      Serial.println(“Stop”);

      stopM();

    }

  }

}

Step 15: Controlling Motors Using Serial Monitor

Open the Serial Monitor.

Send Commands: Type one of the following commands in the input field and press Enter:

‘T’: Start the motors at the initial speed.

‘F’: Move the motors forward.

‘B’: Move the motors backward.

‘L’: Turn left by rotating Motor 1.

‘R’: Turn right by rotating Motor 2.

‘S’: Stop both motors.

 

 

Lesson 4: Introduction to 3D Design with Tinkercad and 3D Printing

Objective:This lesson will cover the fundamentals of 3D design using Tinkercad and introduce the basics of 3D printing. Participants will learn how to create and manipulate 3D models in Tinkercad, equipping them with the skills needed for real-world 3D printing applications.

Step 1: Introduction to 3D Design (10 minutes)

-Open Tinkercad and navigate to the “3D Design” section.

 

             

 

Step 2: Getting Started with Tinkercad (15 minutes)

-Explore the Tinkercad 3D interface and its basic tools.

-Overview of basic functions:

  • Move: This function allows you to reposition an object in the 3D workspace. You can click and drag an object to move it, or use the arrow keys for precise adjustments. Holding the Shift key while dragging allows for more controlled movements.

 

  • Scale: The scale function lets you resize an object. You can click and drag the white handles that appear around the object to make it larger or smaller. You can also hold the Shift key while scaling to maintain the object’s proportions.

  • Rotate: This function allows you to spin an object around its center point. You can click and drag the circular handles that appear near the object to rotate it in 3D space. You can also enter specific rotation angles in the properties panel for precise adjustments.

  • Group: The group function lets you combine multiple objects into a single entity. When objects are grouped, they move, scale, and rotate together. To group objects, select them all (by holding Shift and clicking on each) and then click the “Group” button or use the keyboard shortcut (Ctrl + G). You can ungroup them later if needed.

add 1 block

 

add a second block 

 

select both

 

click on group

 

results

 

 

Step 3: Creating Simple Shapes

-Create basic shapes like cubes, cylinders, and spheres.

-Modify shapes by resizing, rotating, and combining them.

-Experiment with color and alignment.

 

Step 4: Designing a Simple Object

Design a simple object such as a keychain with your name

You can select only one option

 

Step 5: Experimentation 

Continue experimenting with your design. 

-Add details or combine shapes creatively.

-Explore different design possibilities and make changes as needed.

 

Lesson 4.2 Downloading and Preparing SVG and STL Files for Fabrication

Objective: Students will download the necessary SVG and STL files from Tinkercad, prepare them for laser cutting and 3D printing, and assemble the components to build a functioning rover.

 

Complete rover design:

complete rover design 

Step 1 Download SVG Files for Laser Cutting

Links to SVG:

Rover_base_bottom (I will be using this one).

Rover_base_top

Rover_base_Right_side

Rover_base_left_side

Rover_base_back

Rover_base_front   

  • Click on the link provided for any of the laser-cut rover parts (sides, front, bottom, top etc).
  • You will be redirected to this:
  • In Tinkercad, click on the Export button at the top-right.
  • Select SVG format, then click Download.
  • Save the file to your computer.

Step 2  Repeat for All Laser Cutting Parts

  • Repeat Step 1 until you have downloaded all the required SVG parts (sides 1 and 2, front, bottom, top etc).

 

Step 3 Upload SVG Files to the Laser Cutter

  • Transfer the downloaded SVG files (sides, front, bottom, top) to the computer connected to your laser cutter.
  • Upload each file into the laser cutting software and cut.

Links to STL:

Rover_battery_pack

DC_Motor_support

Rover_caster_wheel    

Step 4 Download STL Files for 3D Printing

  • Click on the link provided for any of the 3D-printed rover parts (castor wheel, holders).
  • In Tinkercad, click the Export button.
  • Select STL format and click Download.
  • Save the file to your computer.

Step 5 Repeat for All 3D Printing Parts

  • Repeat  step 4 until you have downloaded all the required STL parts (castor wheel, holders 1 and 2).

 

Step 6 Upload SVG Files to the Laser Cutter

  • Transfer the downloaded SVG files (sides, front, bottom, top) to the computer connected to your laser cutter.
  • Upload each file into the laser cutting software and follow the instructions to cut each part.

 

Lesson 5: Building and Prototyping

Objective: In this lesson, you will start by preparing for prototyping by reviewing components and instructions and understanding the prototyping process. You will then assemble 3D-printed components with electronic parts, build the circuit based on the schematic, and upload and test their Arduino code. The next steps include integrating the circuit with the rover enclosure, performing initial tests, and completing the final assembly. Finally, you will prepare your projects for presentation, discuss key features and design choices, and wrap up by reviewing the integration of code, electronics, and design, emphasizing the role of prototyping.

3D design of how the rover should look like:

Step 1: Preparing for Prototyping (15 minutes)

-Review the provided components and instructions.

-Brief overview of the prototyping process and how to follow the steps.

 

Step 2: Assembling 3D-Printed Components (20 minutes).

 

-Follow the instructions to assemble the pre-cut rover enclosure with the provided electronic components.

-Ensure all parts fit together correctly and securely.

 

Step 3: Making the Circuit (20 minutes)

 

-Build the circuit as instructed using the provided components.

-Connect the circuit components according to the provided schematic.

 

Step 4: Uploading the Code (20 minutes)

 

-Open the Arduino IDE and upload the provided code to the Arduino board.

-Make sure the code is running correctly and troubleshoot any issues with the circuit or code.

-code:

// MOTOR 1

int motor1enA = 5; // PWM Speed Control

int motor1in1 = 4; // Direction Control

int motor1in2 = 2; // Direction Control

 

// MOTOR 2

int motor2enB = 3; // PWM Speed Control

int motor2in3 = 7; // Direction Control

int motor2in4 = 12; // Direction Control

 

// Serial Communication

int state;

 

void setup() {

  // Start serial communication

  Serial.begin(9600);

 

  // MOTOR 1 OUTPUTS

  pinMode(motor1enA, OUTPUT);

  pinMode(motor1in1, OUTPUT);

  pinMode(motor1in2, OUTPUT);

 

  // MOTOR 2 OUTPUTS

  pinMode(motor2enB, OUTPUT);

  pinMode(motor2in3, OUTPUT);

  pinMode(motor2in4, OUTPUT);

}

 

// Function to start both motors at an initial speed

void startMotors() {

  // Set motor speeds (range: 0 – 255)

  analogWrite(motor1enA, 100); // Motor 1 speed

  analogWrite(motor2enB, 100); // Motor 2 speed

  Serial.println(“Motors started”);

}

 

void forward() {

  // Set both motors to move forward

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

void backward() {

  // Set both motors to move backward

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, HIGH);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, HIGH);

}

 

void left() {

  // Move left by rotating only Motor 1

  digitalWrite(motor1in1, HIGH);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

void right() {

  // Move right by rotating only Motor 2

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, HIGH);

  digitalWrite(motor2in4, LOW);

}

 

void stopM() {

  // Stop both motors

  digitalWrite(motor1in1, LOW);

  digitalWrite(motor1in2, LOW);

  digitalWrite(motor2in3, LOW);

  digitalWrite(motor2in4, LOW);

}

 

void loop() {

  // Check if there is serial input

  if (Serial.available() > 0) {

    state = Serial.read();  // Read the input character

 

    // Motor control based on serial input

    if (state == ‘T’) {

      Serial.println(“Start Motors”);

      startMotors();

    } else if (state == ‘F’) {

      Serial.println(“Go Forward”);

      forward();

    } else if (state == ‘B’) {

      Serial.println(“Go Backward”);

      backward();

    } else if (state == ‘L’) {

      Serial.println(“Go Left”);

      left();

    } else if (state == ‘R’) {

      Serial.println(“Go Right”);

      right();

    } else if (state == ‘S’) {

      Serial.println(“Stop”);

      stopM();

    }

  }

}

Step 5: Testing the Circuit Using the Serial Monitor (20 minutes)

  • Open Serial Monitor: Click the magnifying glass icon in the Arduino IDE or go to Tools > Serial Monitor.
  • Set Baud Rate: Ensure it matches the rate in your code (e.g., 9600).
  • Send Commands: Type commands like ‘F’, ‘B’, ‘L’, ‘R’, or ‘S’ to test your circuit.
  • Check Responses: Verify if the circuit responds correctly to the commands you send.
  • Troubleshoot: Fix any issues based on what you see in the Serial Monitor.

Step 6: Integrating the Circuit with the Enclosure (20 minutes)

 

-Integrate the assembled circuit with the rover enclosure.

-Ensure all components are properly secured and functioning within the enclosure.

 

Step 7: Testing the Prototype (20 minutes)

 

-Perform initial testing to ensure the prototype works as expected.

-Make any necessary adjustments to the design, code, or circuit.

 

Step 8: Final Assembly

-Complete the final assembly of the prototype, ensuring all components are properly integrated and securely in place.

-Conduct a final test to confirm the prototype is working as intended.

 

Step 9: Lesson review

 

  1. Why is it important to follow a schematic when building a circuit, and how did it help in ensuring the correct wiring of components?
  2. Can you explain how the serial monitor helped you test the motors and control the movement of the rover?
  3. What challenges did you encounter while assembling the 3D-printed components with the electronic parts, and how did you overcome them?
  4. What steps would you take if the motors did not respond correctly to the commands sent through the Serial Monitor?
  5. Why is it important to test individual components (like motors) separately before integrating them into the final prototype?

 

 

Lesson Feedback

Contact us

Having trouble? Let us know by completing the form below. We'll do our best to get your issues resolved quickly.

"*" indicates required fields

Name*
Email*
This field is for validation purposes and should be left unchanged.
?