When clouds darken your classroom, how does a tiny device know when to remind you?
A heavy cloud rolls over your school, and the classroom gets dim. A small device on the wall lights up to remind you to switch on the classroom lights. How did the device spot the change?
When you decide whether to switch on the classroom lights, you first notice how bright the room is. That information is your input. You apply a rule: if the room is too dim, switch on the lights. Switching them on is your output.
As the room dims, the light sensor produces a changing voltage. You can follow that analogue signal into the microcontroller. The CPU inside it runs the program and decides whether the reminder should light up. The microcontroller sends a digital signal to set the LED on or off.
Before the reminder comes on, the controller needs information about the light in the room. Which component supplies that information to the controller? Pick one answer.
The light reminder is an embedded system. Its controller is built into a device designed for one job. A laptop also has a CPU and uses inputs and outputs, but you can switch between many different jobs, from editing a video to writing code.
Start with an empty log. Each second, digitise the sensor voltage, use the calibration to get a reading in lux, and log it. Read the enable switch. Set the LED output high if the switch input is high and the reading is below two hundred lux. Otherwise, set it low.
The program turns the reminder on only when both conditions are met. The logged reading is one hundred and eighty lux. Lux measures how much light falls on a surface. The switch input is high, so the reminder is enabled. The reading is below two hundred lux, so the LED turns on.
Keep the enable switch on and use the same rule. The light reading is now exactly two hundred lux. What state should the program set the reminder LED to? Pick one answer.
The sensor measures the light falling on it. It’s easy to think the LED measures light too, because it also deals with light. In this circuit, the LED emits light. Follow the signals: the sensor sends an input to the controller, and the LED responds to the controller’s output.