Day 8: The Echoing Call of Safety

  1. Understand the basics of using buttons and photoresistors.
  2. Learn how to connect components to the HERO R3 and breadboard.
  3. Write and upload code to control the circuit using the Arduino IDE.
  4. Develop further skills in coding and electronics.
  5. Integrate a common household fork into the circuit.

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

After successfully restoring the lost Guardians’ Beacon, Astrid and Gear felt a renewed sense of hope as they illuminated the foggy streets of Cogsworth City. However, as night fell, they heard strange noises echoing through the city’s abandoned buildings. Realizing they needed an enhanced alarm system to detect intruders, Astrid remembered an old trick her father had taught her—using a common household fork to complete a circuit. Today, they would integrate the fork with their adventure kit to create an innovative security system.

Gear: “Astrid, the beacon shines brightly, but these echoes are unsettling. We need an enhanced alarm to stay safe. Let’s use the fork you found to complete our circuit. Are you ready to create an advanced alarm system?”

Astrid: “I’m ready, Gear. Let’s use everything we have to protect ourselves.”

Gear: “Astrid, today we’re going to use buttons and a photoresistor to create an advanced alarm system.”

Astrid: “How do these components work together, Gear?”

Gear: “The buttons will act as switches to activate the LEDs, and the photoresistor will adjust the brightness based on ambient light. We’ll use the fork to complete the circuit.”

– Place the HERO board on your work surface.
– Place the breadboard next to the HERO board.
– Place the buttons, LEDs, photoresistor, and fork on the breadboard, each spaced apart.

– Connect one side of the first button to digital pin 2 on the HERO board using a jumper wire.
– Connect one side of the second button to digital pin 3 on the HERO board using a jumper wire.
– Connect the other side of each button to the ground (GND) rail on the breadboard through 10k ohm resistors.
– Connect the other side of each button to the 5V rail on the breadboard.

– Place the LEDs on the breadboard, spaced apart.
– Connect the long leg (anode) of the first LED to digital pin 8 on the HERO board using a jumper wire.
– Connect the short leg (cathode) of the first LED to the ground (GND) rail on the breadboard through a 220 ohm resistor.
– Repeat these steps for the second and third LEDs, connecting them to digital pins 9 and 10, respectively.

– Place the photoresistor on the breadboard.
– Connect one end of the photoresistor to the 5V rail on the breadboard.
– Connect the other end of the photoresistor to an analog pin on the HERO board (A0) and to one end of a 10k ohm resistor.
– Connect the other end of the 10k ohm resistor to the ground (GND) rail on the breadboard.

– Connect one prong of the fork to the positive lead of the first LED using a jumper wire.
– Connect the other prong of the fork to digital pin 7 on the HERO board using a jumper wire.
– The fork will act as a switch to complete the circuit when touched.

Gear: “Astrid, do you know why we use the fork in our circuit?”

Astrid: “Because you’re hungry?”

Gear: “Well yes but, the fork acts like a switch in our circuit. When you touch the fork, it completes the circuit by allowing electricity to flow through it. Think of it like turning on a light switch. When the switch is on, the light turns on because electricity can flow through. When the switch is off, the light turns off because the electricity can’t flow. The fork works the same way. When you touch it, you close the circuit and allow the current to flow, lighting up the LED.”

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

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

Gear: “We’ll write a code that reads data from the buttons and the photoresistor. If the buttons are pressed and the fork is touched, the LEDs will light up. 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 and touch the fork to see if the LEDs light up with brightness adjusted based on the ambient light. This will confirm that our alarm system is working.”

Astrid: “It works, Gear! The LEDs light up and adjust brightness based on the light levels when the buttons are pressed and the fork is touched. We’ve created an effective alarm system!”

Post a comment

Leave a Comment

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