Robot courier Lesson 1.1 All coursesFor teachersStudy in the app Student Arduino Uno + L298P motor shield
Topic 1 · Lesson 1.1

Assembling the robot and reviving the board

Assemble the robot and test each installed component with a diagnostic sketch.

2 × 45 min1–2 students per robotAssembly

Lesson result

Assembled robot: both motors are checked in both directions and stop, both line sensors react to white and black. The test results are recorded in a log.

You will learn

  • Assemble the robot chassis according to the instructions and check each unit.
  • Distinguish between the front, back, left and right sides of the robot.
  • Upload the program to the Arduino and explain what setup() and loop() do.
  • Check both motors, their stop and both line sensors; distinguish the program command from the observed result.

Need to know

Nothing - this is the first lesson.

Will need

Base 130 × 150Motor bracketMotor bracket (mirror)Geared motor × 2Wheel × 2Ball jointArduino holderArduino Uno R3Motor shield L298P (Amp)Sensor stripLine sensor (analog, Trema) × 2Switch mountingMotor battery compartment with switchUSB cable for ArduinoFasteners: screws, nuts, washers, standsScrewdriver

Why this lesson

Throughout the course you will work with one robot - your own. Today you will assemble its chassis, install the “brain” of the robot - the Arduino board - and write the first program. By the end of the lesson, you will have tested each unit installed and recorded that it actually works.

Ready-made robot courier: platform on two wheels, control board, front sensors and gripper
This is what the robot will look like at the end of the course. Today we are assembling the base: platform, motors, wheels, board and line sensors.
Security

While assembly is in progress, the battery compartment is disconnected and the USB cable is not connected to the computer. The battery compartment is connected to the shield in advance by an adult. You turn the motors on and off only with a switch.

1
Lesson 1 · 45 min
Chassis
1

Assign roles

3 min

What should a robot do. First, the robot needs to correctly execute individual commands: rotate each wheel, stop and report sensor readings. Before our independent trip, we will check each component in turn to look for the cause of the error in one place.

What we use and how it works. Arduino Uno is executing the program. The L298P driver uses its signals to control the power supply to the motors: the DIR pin sets the direction, PWM - the proportion of power supply time. The motor converts electrical energy into rotation, and the wheel into movement. Two reflection sensors on the bottom help distinguish between a light surface and a black line.

How to link a dimension to an action. The command and the result are two different things. The inscription in the monitor means that the program has reached printing; We check the rotation with our eyes. On the stand, we will check both directions of each wheel and the stop, then compare the readings of the sensors above the white and black cards. This way we’ll find out exactly how our robot is assembled.

You are working together. One - Pilot: holds parts and a screwdriver. Second - Navigator: reads the step out loud, provides the details and checks the result using the picture.

  1. Decide who starts as Pilot.
  2. After each part that is secured with screws, switch roles.
It should work

Everyone knows their role. The navigator holds the instructions, the pilot holds the instrument.

2

Lay out the parts

7 min

Find every part before assembling. This way you won’t confuse similar parts and will immediately see if something is missing.

Base 130 × 150
1 pc.
Motor bracket
1 pc.
Motor bracket (mirror)
1 pc.
Sensor strip
1 pc.
Arduino holder
1 pc.
Switch mounting
1 pc.
Wheel
2 pcs.
  1. Arrange the printed parts in a row, like on cards.
  2. Find two motor brackets. They are similar, but mirrored: put them side by side and look - the shelves face in different directions.
  3. Place the purchased parts nearby: Arduino, motor shield, two motors, a ball joint, two line sensors, a battery compartment and bags with fasteners.
It should work

All the details are in front of you. You can show both mirror brackets.

Hint: Missing part

Don't replace it with something similar. Check the package with cards again; If there are no details, tell an adult.

3

Practice on one screw

4 min

Almost all parts of the robot are held on by screws and nuts. Let's assemble one connection on the table.

  1. Take a screw, two washers and a nut from the Training bag.
  2. Place the washer on the screw, slide the screw through the two pieces, put the second washer on and screw the nut on with your fingers.
  3. Hold the nut with your finger and tighten the screw with a screwdriver. Stop as soon as the parts stop moving.
The base of the robot from above: a grid of holes, a large rectangular window and a small square one
Grid of base holes. We will attach all the components through these holes.
It should work

Connection order: screw → washer → part → part → washer → nut. The parts don't wobble.

How it works: Why you can’t tighten it with all your might

The parts are printed from plastic. If you overtighten the screw, the plastic will press through or crack. A sign of overtightening - the part bends or turns white around the screw.

4

Agree where in front

3 min

So that “left wheel” always means the same thing, let’s mark the front of the robot.

  1. Lay the base flat: a small square window is further away from you, a long rectangular window is closer.
  2. Far side - before. Stick a paper forward arrow on it.
  3. Define left and right as the driver who sits in the robot and looks in the direction of the arrow.
It should work

There is a forward arrow on the base. You both show the left side of the robot the same way.

5

Attach the motor brackets

8 min

Brackets hold the motors from the bottom of the base.

Base at the bottom with two attached brackets, highlighted in orange
Bottom view. New parts are highlighted in orange.
  1. Turn the base over so that the arrow remains visible from the side.
  2. Place the brackets on the bottom side as shown. Big round holes look out out - the wheel axles will go there.
  3. Insert the screws from above and fit the washers and nuts underneath. Start all screws loosely by hand, then tighten them.
It should work

The two brackets are facing each other, the large holes are on the outside. The brackets do not swing.

Test yourself
6

Install the motors

8 min

The motor axis is a rotating rod on which the wheel fits. It should come out through the hole in the bracket.

Base from below: two motors installed in brackets, axles extending outwards
The motor housing is inside, the axle is outside.
  1. Attach the first motor to the bracket from the inside. The axis passes through a large hole outward.
  2. Secure the motor with the screws from the Motors package. Hold the motor with your hand while you tighten it.
  3. Also install the second motor.
  4. Label the wires: L - left motor, P - right. Check the forward arrow.
It should work

Both motors are held tightly, the axes point left and right, the wires are labeled.

Hint: The motor does not fit into the bracket

Don't press or file. Check if this is the right bracket: maybe you took a mirror one for the other side.

7

Put on the wheels

5 min
  1. Align the wheel hole with the motor axle. The shape of the hole must match the shape of the axis.
  2. Put the wheel on while holding the motor by the housing. Don't hit the wheel.
  3. Look from the side: the wheel should not touch the bracket or base.
Base with two wheels, side-top view
There is a gap visible between the wheel and the bracket.
It should work

Two wheels stand on axles and do not touch anything.

8

Add a back support and check the robot

7 min

There are two wheels, so the robot needs a third support point at the back - a ball joint.

Base with wheels and support on racks at the rear
The support is attached from below at the rear side of the base on racks.
  1. Attach the ball joint from below to the back side of the base. The racks from the “Support” package are selected in height.
  2. Place the robot on the table. It should stand exactly on two wheels and a support.
  3. Gently rock the robot. Nothing should be loose.
It should work

The robot stands stable and level. The chassis is ready.

Test yourself
2
Lesson 2 · 45 min
Electronics and the first program
9

Install Arduino

6 min

Arduino is the “brain” of the robot. The board lies on the holder so that its contacts from below do not touch the screws.

Holder with robot-based Arduino board, highlighted in orange
Holder and board in the center of the base.
  1. Secure the Arduino holder in the center of the base with the posts facing up.
  2. Place the board on the stands so that the USB connector is at the edge and can be reached.
  3. Secure the board with screws. Tighten them one by one, little by little.
It should work

The board lies flat and does not touch the base screws. The USB connector is free.

10

Prepare your computer

5 min

Programs for the robot are written in MyRobotica. It has lessons and a code editor.

  1. Connect the USB cable to the Arduino and to the computer. The battery compartment of the motors remains disconnected.
  2. Open MyRobotica course "Robot Courier" and lesson 1.1. Open the lesson project.
  3. On the right side of the button Upload to robot choose your real robot. B More about communication check the board Arduino Uno and its port.
  4. Leave empty functions in the editor setup() and loop() and save the program.
It should work

The ON power indicator on the board is lit. In MyRobotica, the tutorial project is open, a real robot with an Arduino Uno board is selected, and its port is visible.

Hint: I don't see the port

Disconnect and reconnect the cable. If the port still does not appear, the cable may only charge and not transmit data. Ask for another cable.

Programs for the robot are written in MyRobotica. It has lessons and a code editor.

  1. Connect the USB cable to the Arduino and to the computer. The battery compartment of the motors remains disconnected.
  2. Open MyRobotica course "Robot Courier", lesson 1.1 and his study project.
  3. On the right side of the button Upload to robot choose your real robot. Open up More about communication and check the board Arduino Uno. Unplug the USB cable, see how the connection status changes, and plug it in again. Log the port name.
  4. Leave empty functions in the editor setup() and loop() and save the program.
It should work

A tutorial project is opened in MyRobotica and a real robot with an Arduino Uno board is selected. Its port name is recorded.

Hint: The port never appeared

The cable can only charge and not transmit data. Ask for another cable.

  1. Connect the USB cable to the Arduino and to the computer. The battery compartment of the motors remains disconnected.
  2. Open a course in MyRobotica "Robot Courier", lesson 1.1 and his educational project. On the right side of the button Upload to robot choose your real robot. Via More about communication check the board Arduino Uno and find its port.
  3. Save the program with empty setup() and loop(), click Check code, and then Upload to robot.
  4. Write down in the log: board, port, MyRobotica version and what Check code is different from Upload to robot - what each button does and whether a board is needed for it.
It should work

The empty sketch has been verified and uploaded. The logbook contains the board, port, MyRobotica version and the difference between the two buttons.

Hint: Check the code and Upload to the robot

Disconnect the cable and press both buttons in turn. Which one worked without paying?

12

Put on the shield and connect the motors

7 min

Arduino pins cannot supply enough current to motors. Therefore, the motors are connected to shield - a board that is placed on top of the Arduino and turns on the motors according to its commands.

Security

First, unplug the USB cable. Do not connect or disconnect anything while the board is powered.

  1. Align the shield legs with the Arduino sockets and gently press on top. No leg should be left out or bent.
  2. Connect the motor wires to the shield terminals:
What we connectWhere
Left motor
Label the wires with the letter "L".
M2 channel terminals on the shield
Right motor
Label the wires with the letter "P".
Channel M1 terminals on the shield
Battery compartment (via switch)adult
An adult connects.
Motor power terminals on the shield
  1. The battery compartment with the switch is already connected by an adult. Check that the switch is off. If the compartment wires are not connected, do not connect them yourself, call an adult.
It should work

The shield sits flat on the Arduino. The motor wires are secured in terminals and labeled.

13

Install line sensors

6 min

Line sensors will "look" at the floor and notice a black line. We place them in front, across the robot.

  1. Attach the sensor strip from the bottom at the front edge of the base to the posts.
  2. Attach two sensors to the bar - left and right - with the sensitive side down, to the floor. The sensors are at the same height.
  3. Connect the sensors to the shield according to the table. The letters of the sensor contacts are: S - signal, V - power, G - ground.
What we connectWhere
Left sensor S (signal)A4
Left sensor V (power)5V
Left sensor G (ground)GND
Right sensor S (signal)A5
Right sensor V (power)5V
Right sensor G (ground)GND
  1. Lay the wires so that they do not touch the wheels.
It should work

Two sensors face down, their wires are connected and do not hang down to the wheels.

14

Check all robot components

14 min

Now let's check that every part of the robot works: both wheels and both sensors. The verification program is already open in the editor on the right.

Security

Place the robot on the stand so that the wheels hang in the air and do not touch the table. While the motor switch is off, the wheels cannot spin.

There is no need to write a program - it is ready. You will send her letters and numbers, and she will spin one wheel or show the numbers of the sensors.

Ready diagnosticsL11_Diagnostics.ino.ino
// Программа проверки для робота курса (Arduino Uno + шилд L298P).// Робот стоит на подставке: колёса висят в воздухе.// Колесо крутится со скоростью 120 из 255 около 0,3 секунды.const int LEFT_DIR = 7;const int LEFT_PWM = 6;const int RIGHT_DIR = 4;const int RIGHT_PWM = 5;const int LEFT_SENSOR = A4;const int RIGHT_SENSOR = A5;const int FORWARD = HIGH;const int BACKWARD = LOW;const int TEST_PWM = 120;const unsigned long PULSE_MS = 300;bool running = false;unsigned long startedAt = 0; void reportSensors() {  Serial.print("LEFT=");  Serial.print(analogRead(LEFT_SENSOR));  Serial.print(" RIGHT=");  Serial.println(analogRead(RIGHT_SENSOR));} void beginPulse(int dirPin, int pwmPin, int direction) {  digitalWrite(dirPin, direction);  analogWrite(pwmPin, TEST_PWM);} // ===== Готовая оболочка — не меняй =====void stopMotors() {  analogWrite(LEFT_PWM, 0);  analogWrite(RIGHT_PWM, 0);  running = false;} void setup() {  pinMode(LEFT_PWM, OUTPUT);  pinMode(RIGHT_PWM, OUTPUT);  stopMotors();  pinMode(LEFT_DIR, OUTPUT);  pinMode(RIGHT_DIR, OUTPUT);  pinMode(LEFT_SENSOR, INPUT);  pinMode(RIGHT_SENSOR, INPUT);  Serial.begin(9600);  Serial.println("READY: 1=L forward, 2=L backward, 3=R forward, 4=R backward, d=sensors, s=stop");} void loop() {  if (running && millis() - startedAt >= PULSE_MS) {    stopMotors();    Serial.println("PWM=0; verify physical stop");  }  if (!Serial.available()) return;  char command = Serial.read();  if (command == 's') {    stopMotors();    Serial.println("PWM=0; verify physical stop");    return;  }  // Пока идёт импульс, новые команды не продлевают и не перезапускают его.  if (running) return;  if (command == 'd') {    reportSensors();    return;  }  if (command < '1' || command > '4') return;  // Удаляем накопленные команды: один ввод не должен запускать очередь движений.  while (Serial.available()) Serial.read();  stopMotors();  startedAt = millis();  running = true;  if (command == '1') beginPulse(LEFT_DIR, LEFT_PWM, FORWARD);  if (command == '2') beginPulse(LEFT_DIR, LEFT_PWM, BACKWARD);  if (command == '3') beginPulse(RIGHT_DIR, RIGHT_PWM, FORWARD);  if (command == '4') beginPulse(RIGHT_DIR, RIGHT_PWM, BACKWARD);  Serial.println("Observe wheel; no automatic hardware PASS");}
How it works: What the program does
  • reportSensors prints two numbers: what the left and right sensor sees.
  • beginPulse includes one wheel.
  • After 0.3 seconds the wheel stops itself: this does stopMotors.

Everything in the program is already ready, except for two functions in the “Your part” section. Add them:

  • reportSensors — prints the numbers of the left and right sensor with captions;
  • beginPulse - turns the selected motor in the desired direction at speed TEST_PWM. The second motor is turned off.

Don't change the rest of the program.

Add two functionsL11_Diagnostics_Gaps.ino.ino
// Программа проверки для робота курса (Arduino Uno + шилд L298P).// Робот стоит на подставке: колёса висят в воздухе.// Колесо крутится со скоростью 120 из 255 около 0,3 секунды.const int LEFT_DIR = 7;const int LEFT_PWM = 6;const int RIGHT_DIR = 4;const int RIGHT_PWM = 5;const int LEFT_SENSOR = A4;const int RIGHT_SENSOR = A5;const int FORWARD = HIGH;const int BACKWARD = LOW;const int TEST_PWM = 120;const unsigned long PULSE_MS = 300;bool running = false;unsigned long startedAt = 0; // ===== Твоя часть =====void reportSensors() {  // Цель: показать в мониторе подписанные показания левого и правого датчиков.} void beginPulse(int dirPin, int pwmPin, int direction) {  // Цель: включить только указанный мотор с указанным направлением и TEST_PWM.} // ===== Готовая оболочка — не меняй =====void stopMotors() {  analogWrite(LEFT_PWM, 0);  analogWrite(RIGHT_PWM, 0);  running = false;} void setup() {  pinMode(LEFT_PWM, OUTPUT);  pinMode(RIGHT_PWM, OUTPUT);  stopMotors();  pinMode(LEFT_DIR, OUTPUT);  pinMode(RIGHT_DIR, OUTPUT);  pinMode(LEFT_SENSOR, INPUT);  pinMode(RIGHT_SENSOR, INPUT);  Serial.begin(9600);  Serial.println("READY: 1=L forward, 2=L backward, 3=R forward, 4=R backward, d=sensors, s=stop");} void loop() {  if (running && millis() - startedAt >= PULSE_MS) {    stopMotors();    Serial.println("PWM=0; verify physical stop");  }  if (!Serial.available()) return;  char command = Serial.read();  if (command == 's') {    stopMotors();    Serial.println("PWM=0; verify physical stop");    return;  }  // Пока идёт импульс, новые команды не продлевают и не перезапускают его.  if (running) return;  if (command == 'd') {    reportSensors();    return;  }  if (command < '1' || command > '4') return;  // Удаляем накопленные команды: один ввод не должен запускать очередь движений.  while (Serial.available()) Serial.read();  stopMotors();  startedAt = millis();  running = true;  if (command == '1') beginPulse(LEFT_DIR, LEFT_PWM, FORWARD);  if (command == '2') beginPulse(LEFT_DIR, LEFT_PWM, BACKWARD);  if (command == '3') beginPulse(RIGHT_DIR, RIGHT_PWM, FORWARD);  if (command == '4') beginPulse(RIGHT_DIR, RIGHT_PWM, BACKWARD);  Serial.println("Observe wheel; no automatic hardware PASS");}
Hint: Where to start

Find it in Arduino Help analogRead, Serial.print, digitalWrite and analogWrite. Check the sensors first - you don't need motors for this.

Write the program yourself. The blank contains only contact numbers and turning off the motors.

Write your diagnosisL11_Diagnostics_Empty.ino.ino
// Программа проверки для робота курса (Arduino Uno + шилд L298P).// Робот стоит на подставке: колёса висят в воздухе.// Колесо крутится со скоростью 120 из 255 около 0,3 секунды.const int LEFT_DIR = 7;const int LEFT_PWM = 6;const int RIGHT_DIR = 4;const int RIGHT_PWM = 5;const int LEFT_SENSOR = A4;const int RIGHT_SENSOR = A5;const int FORWARD = HIGH;const int BACKWARD = LOW;const int TEST_PWM = 120;const unsigned long PULSE_MS = 300;bool running = false;unsigned long startedAt = 0; // Напиши диагностику по требованиям урока. При включении моторы стоят.void setup() {  pinMode(LEFT_PWM, OUTPUT);  pinMode(RIGHT_PWM, OUTPUT);  analogWrite(LEFT_PWM, 0);  analogWrite(RIGHT_PWM, 0);} void loop() {}

What the program should be able to do:

  • work with Serial Monitor at speed 9600;
  • by letter d print signed numbers of both sensors;
  • by 1 and 2 turn the left wheel forward and backward, 3 and 4 - right;
  • spin each time at speed 120 for no longer than 300 ms, then turn off both motors;
  • by letter s turn off both motors at once, even during rotation;
  • after turning on and the Reset button, the motors stand until a new command arrives;
  • extra clicks do not accumulate in the queue and do not prolong the rotation.
Hint: How to do without delay

Remember the start time of rotation through millis(). In every aisle loop() check if she has arrived s and whether 300 ms has passed.

How to check a robot

  1. Check the wires. The motor switch is off. Check the wires with the connection tables: each one is in its place and does not touch the wheels. The wheels rotate freely by hand.
  2. Upload the program. Click Upload to robot. Open downstairs Serial Monitor at 9600 speed. The line READY - the board responds. Press the Reset button on the board: the wheels stop.
  3. Check the sensors. Submit d and read the two numbers. Place white paper under the left sensor and send d, then black - and again d. Do the same with the right sensor. On white and black, the numbers should be noticeably different.
  4. Check the wheels. Turn on the motor switch. Send 1 and look at the wheels: only the left wheel turns forward briefly and stops itself. Then send one by one 2, 3 and 4.
  5. Check the stop. Submit 1 and immediately s - the wheel stops. Turn off the motor switch and send 1 once again: the wheels don't spin.
  6. Write down the result to log for each component from the table: command, response in Serial Monitor and actual rotation or sensor reading. If the component has not yet been verified, write down “not verified.” If something is wrong, turn off the motor switch, disconnect the USB, open “If it doesn’t work”, fix it and check this unit again.
What we checkWhat to doIt's good if
FeeLoad the program, click ResetYes READY, the wheels are standing
Left wheelSubmit 1, then 2Only the left one rotates: forward, then back
Right wheelSubmit 3, then 4Only the right one rotates: forward, then back
Left sensord on white and blackThe numbers are noticeably different
Right sensord on white and blackThe numbers are noticeably different
Stops and motor switchThe wheel stops
If it doesn't work
What do you seeWhat to do (motor switch is off)
The wrong wheel is spinningSwap the motor wires at terminals M1 and M2
The wheel spins backwards instead of forwardsSwap the two wires of this motor in the terminal
The wheel doesn't spinCheck that the switch is on and the wires are tightly clamped to the terminals
The sensor number does not changeCheck the S, V, G wires and the height of the sensor above the floor
No line READYCheck the speed of 9600 and the selected port
The wheel spins on its own after ResetCheck that this is the program loaded
Nothing helpsCall an adult and show where you stopped
It should work

You checked each wheel in both directions, both sensors and the stop. The results are recorded in a table.

15

Write the result in the journal

4 min
  1. Write down the date, the robot's name and what happened today in the logbook.
  2. Note which components passed the test immediately and which ones you corrected.
  3. Save the check program - it will come in handy if the robot starts behaving strangely.
It should work

The robot has been checked, the results are recorded in the log, the verification program is saved.

Test yourself

Test yourself

Select answers to prepare. They are not stored or evaluated on the site. Take the knowledge test in the course syllabus or discuss the answers with your instructor.

● Basic

1.What does successful sketch upload confirm?
2.How to check the left motor?
3.What do they check for each line sensor?
4.Why do you need a motor shield?
5.What should I turn off before changing the wiring? Select all answers.

★ Intermediate level

1.What should the sensor reading function output?
2.Left motor selected. What does the right one do?
3.When do they set up the pins and turn off the motors at startup?
4.What does PWM=0 prove?
5.What to do if the sensor produces a constant value?

★★ Advanced level

1.How to ensure that s is processed during a pulse?
2.What does the sketch do after Reset?
3.What to do with the accumulated movement commands?
4.Is it possible to automatically confirm rotation without encoders?
5.All software tests passed, but the wheel does not spin. The result?

Answer questions at your level. Correct answers needed: Beginner - 4 out of 5; Average - 4 out of 5; Advanced - 4 out of 5. Answers will be checked by the teacher or course program.

Summary

You assembled the robot's chassis, installed the board and sensors, and wrote the first program. You confirmed the operation of the installed components with observations. Knowledge testing is required separately. In the next lesson you will move from individual tests on the stand to controlled movement.

How to confirm the result

For each experiment, save the conditions, program version, observation and conclusion. When comparing attempts, change one reason at a time; unsuccessful attempts also remain in the log. Marking a result refers to actions that have already been completed; there is no need to repeat them for the sake of marking. If the result is not obtained, write down the discrepancy and the next hypothesis to be tested. A model, measurements of a real robot, and an explanation are different types of evidence.

Lesson vocabulary

ArduinoA board with a microcontroller - a small computer that runs your program.
shieldA board that fits on top of the Arduino and adds capabilities to it. Our shield controls the motors.
sketchProgram for Arduino.
functionNamed command block. setup and loop are functions.
LEDSmall light bulb on the board. LED L is connected to pin 13.
outputA board pin that a program can control or read a signal from.
msMillisecond is a thousandth of a second. 1000 ms = 1 second.