Day 7: The Lost Beacon

The Lost Beacon

The fog rolls thick through Cogsworth City's industrial district, swallowing streetlamps whole and turning familiar alleys into twisting mazes. You're hunched over your workbench in the underground workshop, the steady tick-tick-tick of the great clocktower above barely audible through the reinforced ceiling. Emergency dispatch crackles over the radio: "All units, we have multiple citizens lost in the Gear Quarter. Standard navigation systems are down due to electromagnetic interference from the storm."

Chief Engineer Valdris slides a weathered schematic across your table. "We need an adaptive beacon system," she says, her voice cutting through the workshop's ambient hum. "Something that responds to available light conditions automatically. When the fog is thick and visibility is near zero, the beacon burns bright. When the morning sun finally breaks through, it dims to conserve power for the next emergency."

You examine the blueprint: three beacon stations positioned at critical intersections, each controlled by a manual activation switch but smart enough to adjust its own brightness based on ambient light. The photoresistor sensors will be your eyes in the fog, measuring exactly how much natural light penetrates the gloom. The microcontroller will be your brain, making split-second decisions about how bright each beacon needs to shine.

The clock tower chimes six times. Dawn is still hours away, and there are people out there counting on you to light their way home. Time to build a beacon that thinks for itself.

What You'll Learn

When you finish building this adaptive beacon system, you'll be able to:

  • Read analog sensor data from a photoresistor to measure light levels
  • Use the map() function to convert sensor readings into usable brightness values
  • Control multiple LEDs with different brightness levels using analogWrite()
  • Combine digital inputs (buttons) with analog inputs (sensors) in one program
  • Create a system that automatically adapts to changing environmental conditions
  • Debug sensor readings using the Serial Monitor

This beacon system represents a major step forward in your engineering skills. You're not just turning things on and off anymore - you're creating intelligent devices that respond to their environment and make decisions based on real-world conditions.

Understanding Adaptive Systems

Think about the automatic headlights on a car. During bright daylight, they stay off to save battery power. As the sun sets or you drive into a tunnel, sensors detect the changing light conditions and gradually brighten the headlights. The dimmer it gets outside, the brighter the lights become. This isn't magic - it's an adaptive system responding to environmental input.

Your beacon system works on the same principle. A photoresistor (also called a light-dependent resistor) acts like an electronic eye. When bright light hits it, its electrical resistance drops low. In darkness, its resistance shoots up high. Your microcontroller reads this changing resistance as a voltage that represents the current light level.

But here's where it gets interesting: the raw numbers your microcontroller reads (0 to 1023) don't directly translate to useful LED brightness values (0 to 255). That's where the map() function becomes your mathematical translator, converting sensor readings into the exact brightness each beacon needs.

The real genius is in combining manual control with automatic adaptation. Emergency personnel can activate specific beacons with pushbuttons when and where they're needed, but once activated, each beacon intelligently adjusts its own brightness. Maximum visibility when the fog is thickest, energy conservation when natural light returns. It's engineering that thinks ahead.

Wiring Your Adaptive Beacon System

Wiring diagram for the adaptive beacon system
  1. Connect the three pushbuttons: Each button gets one leg connected to digital pins 2, 3, and 4 respectively. The other leg of each button connects to ground (GND). These create your manual beacon activation switches.
  2. Wire the three LEDs: Connect the long leg (anode) of each LED to digital pins 8, 9, and 10 through 220-ohm resistors. The short leg (cathode) of each LED connects to ground. These pins support PWM for brightness control.
  3. Install the photoresistor: One leg connects to analog pin A0, the other leg connects to ground. Add a 10k-ohm resistor between A0 and the 5V power rail to create a voltage divider circuit.
  4. Ground connections: