Neon Realm

Day 10: Interactive Lighting – Combining Photoresistor, Buttons, and LEDs

Day 10: Interactive Lighting – Combining Photoresistor, Buttons, and LEDs


Welcome to Day 10 of your adventure with Kai and Orion! Today, we’ll combine all the skills you’ve learned to create an interactive lighting circuit using renewable energy sources. This final mission will

demonstrate the importance of renewable energy and sustainability. Let’s dive into our mission!


Learning Objectives


By the end of this lesson, you will:


  • Understand how to integrate multiple inputs (photoresistor and buttons) and outputs (LEDs) in a complex circuit.
  • Learn how to write and upload MicroPython code to control LEDs based on light levels and button inputs.
  • Develop skills in designing and implementing interactive electronic systems.


Materials Needed


  • Raspberry Pi Pico W
  • USB cable
  • Breadboard
  • Multiple LEDs
  • Photoresistors
  • 2 Buttons
  • Resistors (220 ohm, 10K)
  • Jumper wires (Male to Male)


Story Introduction:


Setting: Kai’s makeshift lab in the old tech shop.


Initial Situation: After mastering individual components, Kai and Orion are ready to create a more complex interactive lighting system that responds to both light levels and button inputs.


Scene Introduction: Kai adjusted his steampunk goggles, excited about the new challenge. “Combining a photoresistor, buttons, and multiple LEDs sounds complex but fun!” he said. Orion hovered closer, ready to guide him through the process.


Call to Action: Orion explains the importance of integrating multiple inputs and outputs to create more sophisticated and interactive systems.


Setting Up the Scene


  • Story: Kai and Orion gather their materials in the tech shop, setting up their lab.
  • Activity: Gather your materials and prepare your workspace.


Kai: Arranging the components on the workbench “Alright, I’m ready. What’s next, Orion?”

Orion: Hovering near the workbench, eyes glowing “First, let’s set up our photoresistor, buttons, and LEDs circuit.”


Introduction to Concepts


  • Story: Orion explains how to integrate multiple inputs and outputs in a circuit and the role of each component.
  • Activity: Learn about how to connect and control LEDs using a photoresistor and buttons.


Orion’s Explanation:


Orion: “We will use the photoresistor to measure the ambient light level and adjust the brightness of an LED using PWM. The buttons will be used to toggle different modes and control additional LEDs.”


Practical Application


  • Story: Kai connects the components under Orion’s guidance, creating a circuit with a photoresistor, buttons, and multiple LEDs.
  • Activity: Connect the photoresistor, buttons, and LEDs to the breadboard and integrate them with the Raspberry Pi Pico WH.


Orion’s Tutorial on Wiring the Circuit:


  1. Orion: “Connect one leg of the photoresistor to the 3.3V rail on the breadboard.”
  2. Orion: “Connect the other leg of the photoresistor to a GPIO pin on the Raspberry Pi Pico WH (e.g., GPIO 26).”
  3. Orion: “Connect a resistor from the GPIO pin to the ground rail on the breadboard.”
  4. Orion: “Connect the negative (shorter) leg of the main LED to a resistor.”
  5. Orion: “Connect the other end of the resistor to the ground rail of the breadboard”
  6. Orion: “Connect the positive (longer) leg of the LED to a GPIO pin on the Raspberry Pi Pico WH (e.g., GPIO 15).
  7. Orion: “Connect one leg of each button to separate GPIO pins on the Raspberry Pi Pico WH (e.g., GPIO 16 and GPIO 17).”
  8. Orion: “Connect the other leg of each button to the power rails rail on the breadboard.
  9. Orion: “Connect the additional LEDs to separate GPIO pins on the Raspberry Pi Pico WH (e.g., GPIO 13 and GPIO 14) with resistors, and connect their negative legs to a resistor connected the ground rail.”


Kai: Placing the components with care “I think I’ve got it. How does this look?”


Circuit Diagram

Orion: Inspecting the setup