Day 7: The Lost Beacon

  1.  Understand the basics of using buttons to control LEDs.
  2. Learn how to connect multiple LEDs, buttons, and a photoresistor to the HERO R3 and breadboard.
  3. Write and upload code to control LEDs using buttons and adjust brightness with a photoresistor using the Arduino IDE.
  4. Develop further skills in coding and electronics.
  5. Learn how to calculate resistor values using Ohm’s Law.

– HERO board
– USB cable
– Breadboard
– 3 LEDs (different colors)
– 3 Buttons
– 1 Photoresistor
– Resistors (220 ohm, 10k ohm)
– Jumper wires (Male to Male)

Astrid and Gear had made significant progress by mastering various sensors and circuits. However, Cogsworth City was still shrouded in darkness and mystery. As they explored deeper into the city’s mechanical heart, they discovered an ancient beacon that once guided travelers safely through the foggy nights. The beacon had been inactive for centuries, but Astrid and Gear realized that by harnessing their knowledge and the components in their adventure kit, they could restore it to its former glory. Today, they would create a multi-colored LED beacon controlled by buttons and a photoresistor to automatically adjust the brightness based on ambient light.

Gear: “Astrid, we’ve discovered the old beacon! If we can restore it, we’ll have a powerful tool to signal our location and find our way through the city. Today, we’ll use our HERO board, LEDs, buttons, and a photoresistor to build this beacon. Are you ready to bring light back to Cogsworth?”

Astrid: “I’m ready, Gear. Let’s restore the beacon and guide our way.”

Gear: “Astrid, today we’re going to use buttons to control our LEDs and a photoresistor to adjust their brightness. This will help us create a responsive beacon.”

Astrid: “How do the buttons and LEDs work together, Gear?”

Gear: “The buttons will act as switches to turn the LEDs on and off, and the photoresistor will adjust their brightness based on ambient light.”

Gear: “Astrid, using your knowledge from previous lessons, wire the circuit with the buttons, LEDs, and the photoresistor. Remember to connect everything to the HERO board and the breadboard.”

Astrid: “I’ll do my best, Gear. Let’s see if I can get it right.”

Astrid: “Gear, how do I know which resistors to use?”

Gear: “Great question, Astrid. Let’s review Ohm’s Law to calculate the proper resistor values.”

Gear: “Ohm’s Law states that V = IR, where V is voltage, I is current, and R is resistance.”

Gear: “Let’s say we have a 5V power supply and we want to limit the current through an LED to 20mA (0.02A). Using Ohm’s Law, we can calculate the resistor value.”

Gear: “First, we subtract the LED’s forward voltage (usually about 2V) from the supply voltage: 5V – 2V = 3V.”

Gear: “Then, using Ohm’s Law, we calculate the resistor value: R = V / I = 3V / 0.02A = 150 ohms.”

Gear: “So, we’d choose a resistor value close to 150 ohms. In our kit, we might use a 220-ohm resistor to ensure we don’t exceed the LED’s current rating.”

Gear: “Now, it’s time to write the code to control the LEDs with the buttons and adjust their brightness with the photoresistor.”

Astrid: “I’m ready, Gear. Let’s see if we can make this beacon work.”

Gear: “We’ll write a code that checks if a button is pressed to turn an LED on or off. We’ll also read the light level from the photoresistor to adjust the brightness of the LEDs. Let’s break down the code step-by-step:”
– Open the Arduino IDE on the computer.
– Write the following code:

Astrid: “The code is uploaded, Gear. What now?”

Gear: “Press each button to see if the corresponding LED lights up and adjusts its brightness based on the ambient light. This will confirm that our beacon is working.”

Astrid: “It works, Gear! The LEDs light up and change brightness based on the light levels. We’ve restored the beacon!”

Astrid: “We did it, Gear! The beacon works perfectly. This will help us navigate through Cogsworth.”

Gear: “You did an excellent job, Astrid. Today, you learned how to use buttons to control LEDs and a photoresistor to adjust their brightness. This skill is crucial for our journey.”

– Today, you learned the basics of using buttons to control LEDs.
– You applied your knowledge to wire the circuit independently.
– You calculated resistor values using Ohm’s Law.
– You wrote and uploaded code to control the LEDs with the buttons and adjust their brightness using the photoresistor.
– These skills are essential for creating interactive and responsive circuits.

Gear: “Astrid, we’re making great progress. Tomorrow, we’ll explore using motion sensors to detect movement and create even more interactive projects.”
Astrid: “I can’t wait, Gear. Let’s keep this adventure going!”

Post a comment

Leave a Comment

Your email address will not be published. Required fields are marked *