Electronic environments and embedded systems
Electronic environments and embedded systems tests how inputs, processing and outputs combine in a physical device. You need to read simple circuit diagrams, identify components, and trace a control program.
Core rules and concepts
- An embedded system is a computer dedicated to one task inside a larger product; it usually has a microcontroller with CPU, memory and GPIO pins.
- Inputs include switches, LDRs and temperature sensors. Outputs include LEDs, buzzers and motors. A motor is often driven through a transistor or relay because a GPIO pin cannot supply enough current.
- Digital pins read HIGH or LOW; analog pins read a range. A pull-up or pull-down resistor stops an input from "floating".
- Programs follow a loop: read inputs, make a decision, set outputs, repeat. Use
delayonly when blocking is acceptable.
Worked example
A night light switches an LED on when an LDR reading falls below 300.
loop forever:
light = read analog pin A0
if light < 300:
set pin 9 HIGH
else:
set pin 9 LOW
Reasoning: A0 is an input; pin 9 is an output set with pinMode(9, OUTPUT). The threshold converts a continuous reading into a Boolean decision. Add hysteresis (on below 280, off above 320) to stop flicker near the threshold.
Traps
- Forgetting to set pin modes.
- Wiring an LED without a series resistor.
- Assuming an active-low button reads HIGH when pressed.
- Using a blocking delay that makes the device miss button presses.
- Confusing a sensor (input) with an actuator (output).