Microcontrollers and robots
The board you have in the classroom is not a toy: it is a complete computer, only tiny and dedicated to a single task. With it you are going to build traffic lights, barriers and robots that really sense what is going on around them.
The microcontroller: a tiny computer
Explain what a microcontroller is (a complete but small computer inside a board) and two differences from a desktop computer: what each can do and what each is used for.
Explain what a microcontroller is (a complete but small computer inside a board) and two differences from a desktop computer: what each can do and what each is used for.
Explain how a program reaches the board: where it is written, what happens when it is "uploaded" via the cable, and why the board then works independently without a…
Explain how a program reaches the board: where it is written, what happens when it is "uploaded" via the cable, and why the board then works independently without a computer, running the program in a loop.
Your team must select the hardware platform to build a home automation prototype that controls blinds using servomotors, detects gas leaks and presence in three…
Your team must select the hardware platform to build a home automation prototype that controls blinds using servomotors, detects gas leaks and presence in three different rooms, and displays the status on an LCD screen.
- a) Compare the suitability of using a compact "all-in-one" board (with sensors and LED display integrated on the printed circuit board itself) versus a modular development board with expansion pins and a breadboard. Analyze aspects such as the spatial distribution of the sensors throughout the home and the wiring of power actuators.
- b) If during assembly a student makes a mistake and burns out the temperature sensor due to overvoltage or reverse polarity, analyze the technical and cost impact on the integrated board versus the modular board.
- c) Justify with reasoned arguments which of the two platforms you would choose for this final home automation robotics project and for which of them you would reserve an initial two-hour introductory programming session.
Input and output pins: where everything is connected
The figure shows a microcontroller board with its groups of pins labeled, except for one. The covered pin is the common reference that all the circuits you connect to…
The figure shows a microcontroller board with its groups of pins labeled, except for one.
The covered pin is the common reference that all the circuits you connect to the board return to. Name it and explain what it is for, what the difference is between digital pins (all or nothing) and analog pins (they read continuous values), and what the USB connector is used for.
Classify these items according to whether they connect to an input pin or an output pin on the board, and justify one of each type: a push button, an LED, an LDR, a…
Classify these items according to whether they connect to an input pin or an output pin on the board, and justify one of each type: a push button, an LED, an LDR, a buzzer, and a potentiometer.
State whether these statements are true or false and justify each answer: (a) the board executes the program exactly as written, without translating it first; (b) the…
State whether these statements are true or false and justify each answer: (a) the board executes the program exactly as written, without translating it first; (b) the board pins can handle any current, so the LED can be connected without a resistor; (c) a servo motor can be set to a specific angle commanded by the program; (d) the board remembers the last program even if it is disconnected from the power supply.
The robot's sensors and actuators
The figure shows a mobile robot seen from above, with its elements labeled and its "brain" covered with a question mark. Name the covered part, explain what information…
The figure shows a mobile robot seen from above, with its elements labeled and its "brain" covered with a question mark.
Name the covered part, explain what information it receives from the sensors and what commands it sends to the actuators, and classify the labeled elements (motor wheels, ultrasonic sensor, buzzer, LED, battery) as input, output or power source.
State what each sensor that can be connected to the board measures and a project in which you would use it: ultrasonic sensor (distance), LDR (light), temperature…
State what each sensor that can be connected to the board measures and a project in which you would use it: ultrasonic sensor (distance), LDR (light), temperature sensor, and infrared line sensor (distinguishes light from dark on the ground).
State what each connectable actuator to the board does and a key difference between them: an LED, a buzzer, a servo motor (turns to the exact position commanded), and a…
State what each connectable actuator to the board does and a key difference between them: an LED, a buzzer, a servo motor (turns to the exact position commanded), and a DC motor (rotates continuously at higher or lower speed).
A robot's motors are not powered directly from a board pin, but from the battery via a "motor driver board". Explain why (the pins provide very little current and the…
A robot's motors are not powered directly from a board pin, but from the battery via a "motor driver board". Explain why (the pins provide very little current and the motor requires much more), what role the driver board plays, and how this relates to a relay in electronic circuits.
Programming with conditions: read, compare, act
You want an LED to light up when the room light falls below a certain level. Explain which pin you use to read the LDR (an analogue one), what setting a "threshold" in…
You want an LED to light up when the room light falls below a certain level. Explain which pin you use to read the LDR (an analogue one), what setting a "threshold" in the program means, and write the three key lines in pseudocode: read, compare, and act.
The figure shows the flowchart for controlling a car park barrier using an ultrasonic sensor, but the decision box is covered. Write the condition that the board must…
The figure shows the flowchart for controlling a car park barrier using an ultrasonic sensor, but the decision box is covered.
Write the condition that the board must check (if the measured distance is less than a certain value, a car is present), explain what the loop does while no one arrives, and what would happen if the barrier lowered without waiting a few seconds.
Design a traffic light using the board: decide how many output pins you need and for what, write the sequence of states with their timings (green $4\ \text{s}$, amber…
Design a traffic light using the board: decide how many output pins you need and for what, write the sequence of states with their timings (green $4\ \text{s}$, amber $1\ \text{s}$, red $4\ \text{s}$), and explain why the program is written as an infinite loop.
The ultrasonic sensor and the line follower
An ultrasonic sensor measures distance like a bat. Explain the principle (it emits a sound pulse and measures how long the echo takes to return), why it has two "eyes"…
An ultrasonic sensor measures distance like a bat. Explain the principle (it emits a sound pulse and measures how long the echo takes to return), why it has two "eyes" (one transmitter and one receiver), and two situations in which it might fail: soft objects that absorb sound and inclined surfaces that deflect the echo.
Describe the high-level behaviour of an obstacle-avoiding robot: what the front sensor measures, what the robot does when the path is clear, and what sequence it…
Describe the high-level behaviour of an obstacle-avoiding robot: what the front sensor measures, what the robot does when the path is clear, and what sequence it executes when it detects something close (stop, turn, check again). What would happen if it only had a forward-facing sensor?
You are designing the calibration and assembly of a line-following robot that travels along a white circuit with a 2 cm wide black line. The robot has two infrared…
You are designing the calibration and assembly of a line-following robot that travels along a white circuit with a 2 cm wide black line. The robot has two infrared reflectance sensors ($S_I$ and $S_D$) mounted on the front and differential drive with two independent motors.
- a) Predict what erroneous behaviour the robot will have if you mount the sensors separated by only 1 cm from each other (a distance smaller than the line width). What if you separate them by 6 cm? Justify what the optimal geometric separation should be.
- b) Design the robot's decision table indicating the state of each motor (forward, stop, or reverse) for each of the 4 possible reading combinations (White/Black).
- c) Upon reaching a sharp left turn, if the robot only turns off the left motor and keeps the right motor forward, it tends to leave the line due to inertia. Justify what change you must make in the motor control to achieve a much tighter turn on its own axis.
To control an access barrier with an emergency stop push button, a student programs the following sequence: During testing, when the emergency stop button is pressed…
To control an access barrier with an emergency stop push button, a student programs the following sequence:
open_barrier();
wait(5000); // fixed 5 s pause with delay
close_barrier();
During testing, when the emergency stop button is pressed during the 5 s pause or while the barrier is descending, the system does not respond and continues its cycle, causing an impact.
- a) Explain at the microcontroller execution level why the fixed wait instruction (
delay) blocks responsiveness to the emergency. - b) Design the algorithmic structure (in pseudocode or flowchart) that allows keeping the barrier open for 5 s while continuously checking the stop push button to stop the motor instantaneously.
- c) If you also need a buzzer to emit intermittent 0,5 s beeps while the barrier is moving, justify why this requirement is unfeasible with blocking pauses and how it is solved.
Designing and troubleshooting a real robot
To move a car park barrier, you can use a servo motor or a DC motor. Compare both: which reaches an exact position and stays still, which rotates continuously, which…
To move a car park barrier, you can use a servo motor or a DC motor. Compare both: which reaches an exact position and stays still, which rotates continuously, which requires less extra electronics in this project, and why.
Your program should turn on an LED when a button is pressed, but the opposite occurs: it is on and turns off when pressed. Explain two possible causes (the program logic…
Your program should turn on an LED when a button is pressed, but the opposite occurs: it is on and turns off when pressed. Explain two possible causes (the program logic is inverted or the push button is wired in reverse, "active-low") and how you would test each one.
A group of students has programmed a pedestrian traffic light with a push-button using the following logic: as soon as the pedestrian presses the button, the vehicular…
A group of students has programmed a pedestrian traffic light with a push-button using the following logic: as soon as the pedestrian presses the button, the vehicular light turns instantly from green to red and the pedestrian light turns green for 15 s. After testing it on a road model, they observe sharp braking by vehicles and continuous traffic jams if several pedestrians repeatedly press the button.
- a) Justify two road safety and traffic flow flaws present in this initial program.
- b) Design the flowchart or the corrected timing sequence (indicating inputs, outputs, and recommended times) to resolve both problems, incorporating a transition phase (amber) and guaranteeing a minimum time of continuous green for cars before serving another pedestrian call.
- c) If you want to add an intermittent acoustic buzzer for visually impaired individuals during the last 3 s of the pedestrian green, how should you modify the timing of that output?
In a 10-space car park controlled by a barrier, a student proposes this algorithm: «The entry sensor adds 1 to the cars inside upon detecting a vehicle and opens the…
In a 10-space car park controlled by a barrier, a student proposes this algorithm: «The entry sensor adds 1 to the cars inside upon detecting a vehicle and opens the barrier; the exit sensor subtracts 1 when leaving; if the cars inside reach 10, the FULL light turns on and the barrier does not open». During the first week of testing, the system indicates FULL even though there are empty spaces, and sometimes the barrier hits the roof of the cars.
- a) Analyse and identify two real-world physical situations that cause the counter to become desynchronised over the hours (hints: vehicles that turn back after stepping on the sensor, pedestrians passing through, false detections).
- b) Design the complete control logic (specifying conditions with the entry, barrier, and exit sensors) so that the count is reliable and does not depend on a single instantaneous reading.
- c) What safety condition must have absolute priority in the programming to guarantee that the barrier never lowers while an obstacle or vehicle is crossing?
You are tasked with designing the control and logging system for an environmental station in a school greenhouse using a programmable board. a) Select three suitable…
You are tasked with designing the control and logging system for an environmental station in a school greenhouse using a programmable board.
- a) Select three suitable sensors to monitor plant conditions, classify them as analog or digital, and justify the ideal sampling rate for each (argue why measuring temperature every 10 ms would be a technical error and why measuring it once a day would be insufficient).
- b) Write the Boolean logic condition that simultaneously activates ventilation and automatic irrigation if the temperature exceeds 32 °C and soil moisture falls below 30 %.
- c) Reviewing the daily graphical log data, you observe that at 13:00 the light reading is at its maximum, but the temperature probe suddenly reads 0 °C for 15 minutes before returning to 28 °C. Interpret this anomaly, justifying whether it is due to a meteorological phenomenon or an instrumental fault (wiring/sensor).
A mobile robot programmed with Arduino works perfectly while connected to the computer via the USB cable (the wheels spin in the air and the program executes the entire…
A mobile robot programmed with Arduino works perfectly while connected to the computer via the USB cable (the wheels spin in the air and the program executes the entire sequence). However, when disconnecting the USB, powering it with a 4 AA battery holder (6 V) connected to both the board and the motors, and placing it on the ground, the following occurs: at the exact moment the motors try to start to overcome friction, the board's power LED flickers slightly, the robot gives a small jolt, and the program restarts from the first line in a continuous loop.
- a) Interpret and justify the physical-electrical cause of this failure: what happens to the motors' current demand at the moment of starting and how does it affect the voltage received by the microcontroller?
- b) Why did this problem not manifest itself while the robot was being tested connected via USB with the wheels off the ground?
- c) Propose and justify two technical modifications to the power supply circuit to definitively solve this problem and ensure the stability of the microcontroller.
You must design the autonomous control system for a library messenger robot that transports books between two stations (Table 1 and Table 2) following a line on the…
You must design the autonomous control system for a library messenger robot that transports books between two stations (Table 1 and Table 2) following a line on the floor. The complete cycle consists of: waiting for the start command via a push button, following the line until finding a transverse stop mark, stopping and alerting with a buzzer for 3 s, waiting for the user to remove the book (detected by a presence or weight sensor), and returning to Table 1 by performing a 180° turn to be ready for the next service.
- a) Identify the required sensors and actuators, classifying each as an input or an output.
- b) Design the system's state machine or flowchart, accurately indicating the robot's different states and what condition triggers the transition to the next state.
- c) Add a reactive safety protocol to the design: what sensor must you incorporate and how should the main loop act if a student crosses less than 20 cm in front of the moving robot?