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

Programming Controller Boards

A controller board executes exactly the instructions in its program, whether they are correct or not: it does not interpret intentions. Formalising algorithmic thinking before programming — with pseudocode, flowcharts or state machines — is what separates a program that works by chance from one designed to work every time.

Before you start, make sure you know: Algorithms and computational thinking (2nd ESO)
Before you start, make sure you know: Microcontrollers and robots (3rd ESO)

Algorithm and program

One algorithm, the cycle of a traffic light (green, amber, red and repeat), is expressed as pseudocode, as blocks or as a flowchart, and is translated into a program that a controller board runs with three LEDs. algorithm repeat pseudocode 1repeat forever 2green; wait 3amber; wait 4red; wait blocks repeat forever turn on wait turn on wait turn on wait flowchart green, wait amber, wait red, wait program the same logic is expressed as text, blocks or a flowchart
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

Inputs and conditionals: combining with AND, OR, NOT

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
Explain what a conditional statement ("if... then... else...") is and write the condition needed for these two warnings: an alarm that sounds when a door opens and an…

Explain what a conditional statement ("if... then... else...") is and write the condition needed for these two warnings: an alarm that sounds when a door opens and an alert that beeps when the temperature exceeds $40\ ^\circ\text{C}$.

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

Loops and non-blocking timing

Animation of two timing methods: in the blocking wait a progress bar moves along the rectangle without anything being read; in the non-blocking timer a marker jumps from box to box and flashes in each one to show that the inputs are read on every pass. blocking wait reads nothing the system is "blind" during the wait non-blocking timer keeps checking inputs on every pass
Practice★☆☆Not started
What is the purpose of the "wait" command (a delay) in a control program? Give two examples in which, without that delay, the system would not perform its function.

What is the purpose of the "wait" command (a delay) in a control program? Give two examples in which, without that delay, the system would not perform its function.

Solve
Practice★☆☆Not started
Explain why almost all programs for controller boards contain a loop ("repeat forever") and describe what a set of traffic lights would do if its program did not have a…

Explain why almost all programs for controller boards contain a loop ("repeat forever") and describe what a set of traffic lights would do if its program did not have a loop.

Solve
Practice★★☆Not started
In a pedestrian light system, the program reads the push button only once during each 30-second cycle. Explain what the pedestrian experiences upon pressing it and…

In a pedestrian light system, the program reads the push button only once during each 30-second cycle. Explain what the pedestrian experiences upon pressing it and reason why long delays within the program affect the response speed of the system.

Solve

Flowcharts

Flowchart with start, sensor reading, a decision diamond and a branch into two paths depending on whether the condition is true or false. start read sensor condition? yes action A no action B
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
To automate the watering of a school garden, an analog moisture sensor and an electric pump are available. A first program applies this rule: "repeat forever: if…

To automate the watering of a school garden, an analog moisture sensor and an electric pump are available. A first program applies this rule: "repeat forever: if moisture < 30,0 %, turn pump on; else, turn pump off; wait 1 second".

  1. a) If the sensor reading rapidly fluctuates between 29,8 % and 30,2 % due to localized absorption or electrical noise, predict how the electric pump will behave and what mechanical and electrical consequences it will have.
  2. b) Explain why replacing the wait with "wait 10 minutes" does not guarantee optimal watering either (analyze the delay in water infiltration and the risk of over-irrigation).
  3. c) Design a solution using hysteresis control: define two different logical moisture thresholds (start and stop) and write the structured pseudocode or describe in detail the corresponding flowchart, justifying why it prevents constant switching.
Solve

Waiting sequences versus state machines

Finite state machine diagram of a pedestrian traffic light: green changes to amber after 8 s, amber to red after 2 s and red returns to green after 8 s. green amber red 8 s 2 s 8 s
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
Practice★★★Not started
To control a vehicle traffic light that includes a pedestrian demand push button, two programming structures are compared: Option A (linear sequential): loop with…

To control a vehicle traffic light that includes a pedestrian demand push button, two programming structures are compared:

  • Option A (linear sequential): loop with successive blocking calls wait(t) (green 30 s, amber 3 s, red 15 s).

  • Option B (state machine): the system remains in the CARS_GREEN state and only transitions state if the pedestrian push button signal is detected.

  1. a) Justify why Option A is inadequate to respond immediately to a pedestrian pressing the button and what response flaw it will cause.
  2. b) If you are asked to add a new function ("the pedestrian green light must flash 3 times for 3,0 s before turning red, but only if the sensor for visually impaired people is not active"), explain what modularity and maintenance advantages Option B presents compared to Option A.
  3. c) Design the state diagram or general pseudocode for Option B, clearly identifying the states, input events, and actions associated with each transition.
Solve

Debugging

Debugging a robot program: the sensor sends readings to the board, where the condition and the variable are checked, and the values are printed through the serial port on a monitor; three hypotheses are tested in order. variable if (condition) serial port 0 1 0 1 1 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 0 real values 3 erratic sensor 2 variable not read 1 inverted condition each hypothesis is tested separately, from most to least likely
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
A fan control program states: "if temperature is greater than $26\ ^\circ\text{C}$, turn off fan; if less than $26\ ^\circ\text{C}$, turn on fan". Describe the actual…

A fan control program states: "if temperature is greater than $26\ ^\circ\text{C}$, turn off fan; if less than $26\ ^\circ\text{C}$, turn on fan". Describe the actual behaviour of the fan and write the corrected program.

Solve
Practice★★★Not started
The control system of an automatic toll barrier has a presence sensor 1 (just before the barrier) and a sensor 2 (just after). An operator proposes this code: a) Predict…

The control system of an automatic toll barrier has a presence sensor 1 (just before the barrier) and a sensor 2 (just after). An operator proposes this code:

repeat forever:

    if (sensor_1 == DETECTED) then:

        raise_barrier()

    if (sensor_1 == CLEAR) then:

        lower_barrier()
  1. a) Predict what accident will physically occur as soon as the front of the car passes sensor 1 if the rear part is still under the barrier. Justify why the operator's proposal to "add a 5,0 s pause before lowering" does not solve the problem with slow traffic or articulated vehicles.
  2. b) Design in pseudocode a safe algorithm that uses both sensors to ensure that the barrier raises when the vehicle arrives, stays up as long as either of the two sensors detects presence, and only lowers when the vehicle has completely cleared sensor 2.
Solve

Summary

See all the exercises in this section