IoT and Smart Systems Engineer · Focus area 2: Talking to hardware
IO5: Pins, analog readings and driving things: GPIO, ADC and PWM
Goal: read switches and drive outputs with digital pins, take good analog readings, control brightness and speed with PWM, drive loads such as relays and motors safely, understand a sensor's accuracy and calibration, and protect people and electronics.
You'll need: IO1, IO2, IO4, Module 1 (How Computers Work), Module 22 (Loops and Algorithms), and the JalSetu practice kit
(docs/lv20-datasheet.md, capstone/design-notes-template.md).
Where this is used: every device that senses or moves something: a doorbell button, a soil moisture probe, a fan speed control, a pump relay, a buzzer. Getting the electrical side right decides whether readings can be trusted and whether the device is safe.
How it differs: in software, a value is what you set it to. In electronics, a pin's voltage depends on wiring, noise, resistors and the parts connected to it, and a mistake can damage a board or hurt someone.
Time: reading about 3 hours · practice (the Try it tasks) about 3 hours · assignment about 4 hours.
Lessons
- 1Digital pins: inputs and outputsReading 15–25 minutes, plus practice✓
- 2Analog readings with the ADCReading 15–25 minutes, plus practice✓
- 3PWM and driving loadsReading 15–25 minutes, plus practice✓
- 4Sensors and how far to trust themReading 15–25 minutes, plus practice✓
- 5Protecting people and electronicsReading 15–25 minutes, plus practice✓
🛠️Assignment: JalSetu's hardware additions
- Design a float-switch input for overflow, with its pull-up and debouncing.
- Work out JalSetu's battery measurement through a voltage divider and a 12-bit ADC, with averaging.
- Plan a low-voltage pump control with a driver and a flyback diode (on paper only).
- Write the LV-20's range, resolution and timing, two sanity checks and a calibration method.
- Write a protection plan for the rooftop, marking what needs expert review.
Self-check before you finish:
- [ ] No input floats, and no pin drives a load directly.
- [ ] Every analog conversion shows its steps.
- [ ] Nothing in the plan involves mains wiring.
- [ ] Untested items are marked not verified.
✅Module check
Explain in a few sentences, in your own words:
How do you connect sensors and loads to a microcontroller safely and reliably?
Show a good answer
A good answer mentions: inputs with pull-ups or pull-downs, voltage levels and current limits respected; ADC readings converted with the reference and averaged, with dividers for larger voltages; PWM for brightness and speed, with drivers, shared grounds and flyback diodes for coils; sensor range, resolution, accuracy, calibration and sanity checks; and protection from water, heat, static, reversed power and battery hazards, with mains work left to qualified electricians and certification checked.
📚Official references
Official documentation and guidance for this module's topics, chosen on 2 November 2026. Tools, laws and standards change, so check the current version before you rely on a detail. If a link has moved, search the same site.
📝Module quiz
10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·
