Logic and computer systems · GCSE · OCR J277 1.1.3, AQA 8525 3.4.5, Edexcel 1CP2 3.1.3 · about 15 min
What makes a system embedded, the robot's three boards, and the sense-decide-act loop.
[1 mark]What is an embedded system?
[1 mark]Which is an embedded system?
[1 mark]Which is typical of an embedded system?
[1 mark]Put the steps of the control loop in order.
Number the lines 1 to 3 to put them in the right order.
Decide: work out what to doAct: set the outputsSense: read the inputsSense: read the inputs Decide: work out what to do Act: set the outputs
Then repeat, forever.
[1 mark]What does this program print?
gap = 15
if gap < 20:
action = "stop"
else:
action = "drive"
print(action)stop
15 is under 20, so the decision is stop.
There is a wall ahead. Write a sense-decide-act loop that drives the robot forward slowly. Each time round: sense the distance; decide; act. While the gap is 20 cm or more, keep driving with a green LED. When it is under 20 cm, stop, turn the LED red, play a tone, and end the loop. Do not hit the wall.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect()
The hint students can ask for: Start the robot moving, then loop: read the gap, decide, act. While there is room, keep the LED green. When the gap is too small, stop, turn the LED red, sound the tone and leave the loop.
from bugbot import *
connect()
drive(30, 0)
while True:
gap = distance()
if gap < 20:
stop()
led(255, 0, 0)
tone(880, 0.3)
break
else:
led(0, 255, 0)
wait(0.05)
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.