Back to homeTechnology · 4th ESO A · Change subject
Start for free
ESO Y4A · Technology
Computational thinking and robotics · Robotics

Programming controller boards

A controller board does not interpret your intentions: it executes exactly what you wrote, even if it is wrong. Reading inputs, making decisions, repeating actions and measuring time are the four building blocks of almost any control program, from a set of traffic lights to a line-following robot.

Before you start, make sure you know: Microcontrollers and robots (3rd ESO)
Before you start, make sure you know: Block-based programming (2nd ESO)

Reading inputs: turning the world into numbers

Diagram of a reading in which the physical signal from a sensor is captured by an instruction and stored in a variable ◎sensor leer(pin)→ distancia = 23 variable
Practice★☆☆Not started
Explain what an algorithm is and what a program is, and what difference there is between describing it in pseudocode (using words) and with visual blocks.

Explain what an algorithm is and what a program is, and what difference there is between describing it in pseudocode (using words) and with visual blocks.

Solve
Practice★☆☆Not started
The program instructions for a set of traffic lights are out of order: (a) wait 2 seconds, (b) turn on the red light and turn off the others, (c) turn on the green light…

The program instructions for a set of traffic lights are out of order: (a) wait 2 seconds, (b) turn on the red light and turn off the others, (c) turn on the green light and turn off the others, (d) return to the start, (e) wait 8 seconds (appears twice in the cycle), (f) turn on the amber light and turn off the others. Put them in the correct order and describe what the complete program does.

Solve
Practice★★☆Not started
Write in pseudocode the complete program for a simple set of traffic lights: green for 8 seconds, amber for 2, red for 8, and repeat. Indicate at each step which lights…

Write in pseudocode the complete program for a simple set of traffic lights: green for 8 seconds, amber for 2, red for 8, and repeat. Indicate at each step which lights are on and which are off.

Solve

Making decisions with conditionals

Practice★☆☆Not started
The flowchart in the figure controls a car park entry barrier, but the question inside the decision diamond is missing. Write the condition that should be checked there…

The flowchart in the figure controls a car park entry barrier, but the question inside the decision diamond is missing. Write the condition that should be checked there and describe the complete behaviour of the barrier.

Start Read push button ? yes Raise barrier Wait 5 s Lower barrier no
Solve
Practice★☆☆Not started
Explain what "reading an input" means in a control program and what difference there is between reading a push button (which gives 0 or 1) and reading a light sensor…

Explain what "reading an input" means in a control program and what difference there is between reading a push button (which gives 0 or 1) and reading a light sensor (which gives a number within a range).

Solve
Practice★★☆Not started
A stair light works as follows: pressing the button turns it on; after 30 seconds it turns off automatically; and the cycle can be repeated. Draw or describe its…

A stair light works as follows: pressing the button turns it on; after 30 seconds it turns off automatically; and the cycle can be repeated. Draw or describe its flowchart and then write the corresponding pseudocode.

You can do it on paper and send a photo with your answer.

Solve

Repeating in loops: the program that never ends

Flowchart of the main loop: read sensors, decide and act, and start again indefinitely read sensors decide and act repeat
Practice★☆☆Not started
A program consists of only these lines: "repeat forever: read the push button; if pressed, turn on LED; else, turn off LED". Describe in your own words what the setup…

A program consists of only these lines: "repeat forever: read the push button; if pressed, turn on LED; else, turn off LED". Describe in your own words what the setup does and reason what would happen if the "else, turn off LED" part were deleted.

Solve
Practice★★☆Not started
The flowchart in the figure shows the program for a single-sensor line-following robot tracking the edge of the line, but the condition inside the decision diamond is…

The flowchart in the figure shows the program for a single-sensor line-following robot tracking the edge of the line, but the condition inside the decision diamond is missing. Complete it, describe what the robot does in each case, and reason what will happen when the line ends.

Start Read sensor ? yes Turn to the left no Turn to the right
Solve
Practice★★☆Not started
A car park barrier should only raise when a car is waiting (sensor) and the driver has also taken the ticket (push button); it lowers once the car has passed (a second…

A car park barrier should only raise when a car is waiting (sensor) and the driver has also taken the ticket (push button); it lowers once the car has passed (a second sensor). Write the complete pseudocode for the cycle, combining both conditions at once.

Solve

Measuring time without blocking the program

Animation comparing two time bars: a cursor moves along both the two-second blocking wait, where nothing is read, and the non-blocking timer, where the four blocks light up one after another, each just as the cursor crosses it, like readings on every pass. blocking wait reads nothing, 2 s the robot goes "blind" non-blocking timer keeps reading sensors on every pass
Practice★★☆Not started
A home alarm, upon detecting an open door, waits 10 seconds before sounding to allow time to disarm it using a passcode. Write its pseudocode including the passcode…

A home alarm, upon detecting an open door, waits 10 seconds before sounding to allow time to disarm it using a passcode. Write its pseudocode including the passcode check and explain the purpose of this delay.

Solve
Practice★★☆Not started
A program counts cars: "repeat forever: wait for sensor to change from 0 to 1; add 1 to cars variable". Explain what it does, what purpose it serves, and what problem…

A program counts cars: "repeat forever: wait for sensor to change from 0 to 1; add 1 to cars variable". Explain what it does, what purpose it serves, and what problem arises if a car stops right over the sensor.

Solve
Practice★★★Not started
The flowchart in the figure controls a car park exit barrier, with a sensor positioned beneath the barrier, but one of the conditions is missing. Complete it, describe…

The flowchart in the figure controls a car park exit barrier, with a sensor positioned beneath the barrier, but one of the conditions is missing. Complete it, describe the overall behaviour, and explain what accident this second check prevents.

Start Car waiting? no yes Raise barrier ? no yes Lower barrier
Solve

Debugging a program that does not do what it should

Robot with a light sensor, control board and LED, showing the three points where the fault may lie: a loose wire between the sensor and the board, a wrongly set threshold in the reading and an inverted condition in the program light sensor loose wire reading si luz < umbral wrong threshold inverted logic LED test each one separately, from most to least likely
Practice★★★Not started
A robotics team is testing a line-following robot with two infrared sensors (L and R) spaced 2,0 cm apart, designed to follow a 1,5 cm black line on a white background.…

A robotics team is testing a line-following robot with two infrared sensors (L and R) spaced 2,0 cm apart, designed to follow a 1,5 cm black line on a white background. The current program applies classic logic: move straight if both see white, turn right if R steps on black, and turn left if L steps on black.

  1. a) Predict what will happen on a very sharp 90° turn if the robot enters fast and both sensors end up simultaneously on the white background off the line. Justify why the basic algorithm fails.
  2. b) Design in pseudocode an improvement that uses a memory variable (last_seen) so the robot knows which way to turn when it completely loses the line.
  3. c) If the track had a wide black line of 3,5 cm (wider than the distance between sensors), predict the robot's behavior on a straight section and explain what additional condition you should program to handle when both sensors detect black at the same time.
Solve
Practice★★★Not started
An installer programs a home alarm control unit with a magnetic sensor on the door, another on the window, and an arming switch using this algorithm: a) Analyze the code…

An installer programs a home alarm control unit with a magnetic sensor on the door, another on the window, and an arming switch using this algorithm:

repeat forever:

    if (armed == TRUE) and (door == OPEN or window == OPEN) then:

        activate_siren()

        wait(60) // seconds

        deactivate_siren()
  1. a) Analyze the code and explain two critical security flaws: what happens if an intruder opens the window, enters, and closes it again within 3,0 s? And what happens if the 60 s elapse and the intruder is still inside with the window open?
  2. b) Design in pseudocode a robust algorithm with state variables that ensures: 1) once triggered, the siren will sound for at least 60 s even if the access point is closed again; 2) it will not turn off as long as any sensor remains open; and 3) if the user turns off the arming switch, the siren will stop immediately at any moment.
Solve
Practice★★★Not started
A student programs the lighting for a communal staircase: when the switch is pressed, the light must stay on for 30 s and then turn off. a) If the student implements the…

A student programs the lighting for a communal staircase: when the switch is pressed, the light must stay on for 30 s and then turn off.

  1. a) If the student implements the delay with a blocking function such as wait(30), predict what will happen if a second neighbor presses the switch 15 s after the light has turned on. Does this behavior fulfill the function of a resettable staircase timer? Justify your answer.
  2. b) Design in pseudocode a non-blocking resettable system using a time_remaining variable and periodic checks (for example, every 1,0 s), so that each new press resets the countdown to 30 s without turning the light off.
  3. c) Predict what risk exists if a physical push-button gets stuck and remains permanently activated, and propose a logical modification to prevent the light from staying on indefinitely.
Solve

Summary

See all the exercises in this section