AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Helpers that sense

Week 29 · 4.5 Augmented reality and AI · 3 lessons
2

Sense, decide, act

Computing 8: Topic 4.5, pp. 283–299
GoalExplain sensors and autonomous programming, and trace a sensor program.
New words
sensor · an input device that measures the world around it, such as light or temperatureautonomous · working without a person controlling each stepautonomous programming · a system captures data from its surroundings and makes decisions and takes action by itself
Explanation

A sensor is an input device that takes readings from its surroundings, such as light, temperature or distance. In autonomous programming, a computer system gets readings from sensors, makes a decision from them and takes an action, all without a person controlling it. A street lamp that turns on when it gets dark is an example. Its light sensor sends a number, a program compares it with a limit, and an output switches the lamp on or off. Some autonomous systems also use AI, so they can learn from their readings and make better decisions. Robots in a factory and robots that explore dangerous places use sensors and autonomous programs, because they can work where it is unsafe or boring for people. AI can still be wrong, so people check the results.

sensor: readingdecision: compare with a limitaction: output
Worked examples
Python
1light = int(input("Light level 0 to 100? "))
2if light < 30:
3    print("Lamp on")
4else:
5    print("Lamp off")
Output
Lamp on
A street lamp program. The light sensor gives a number from 0 (dark) to 100 (bright). The lamp comes on when the reading is below 30. With a reading of 12 the lamp turns on. Nobody pressed a switch.
ReadingIs light < 30?Lamp
29trueon
30falseoff
31falseoff
The boundary matters. With 30, the condition light < 30 is false, so the lamp stays off. If the designer meant “30 or darker”, the program needs <= instead. This is the same boundary bug as in earlier weeks.
Sensor readingDecisionAction
parcel length 45 cm45 > 60? nosmall shelf
parcel length 80 cm80 > 60? yesbig shelf
parcel length 60 cm60 > 60? nosmall shelf
A warehouse robot sorts parcels by size. A sensor measures the length of each parcel. If it is over 60 cm, the robot puts it on the big shelf. Otherwise, it uses the small shelf. The robot repeats this for every parcel, without a person. If its sensor gets dirty and gives a wrong number, it makes wrong decisions, so people still check.
Class activity

Be the autonomous system (no computer). Work in threes: one person is the sensor and reads out numbers, one is the decision-maker with a written rule on a card (for example, “if the number is less than 5, say ON, else say OFF”), one is the action (stands up for ON and sits down for OFF). The sensor calls ten numbers, including boundary numbers such as 4, 5 and 6. Does the decision-maker follow the rule exactly? What would happen if the sensor gave a wrong number? Write a rule for a different situation, such as a plant-watering pump that runs when the soil is dry. Swap roles and play again.

Practice
1
A designer changes the test to light <= 30. What does the changed program print when the reading is 30? What about 31?
Python
1light = int(input("Light level 0 to 100? "))
2if light <= 30:
3    print("Lamp on")
4else:
5    print("Lamp off")
2
Name the sensor, the decision and the action in a system that opens a door when someone comes near.
3
Why do people still check robots that use AI?
4
Give one job where it is better for a robot to work autonomously than a person, and say why.