Let me transport you back in time, precisely six years ago, when my 12-year-old son was merely six years old. Ah, the joys of being six!
At that age, six-year-olds possess a peculiar sleep schedule. They tend to sleep in on school days, almost missing the bus each morning. However, come Saturdays, they miraculously wake up an hour earlier than necessary, eagerly seeking out their favorite cartoons.
Understanding the concept of time is still a bit fuzzy for six-year-olds. You can't simply tell them, “Stay in bed until 7:30 am.” And even if you did, they wouldn't comply. So, how can you assist kids in learning to stay in bed until 7:30 am on a Saturday morning? Well, we turned it into a game!
Coincidentally, my son had just received a Raspberry Pi from his grandfather, along with the challenge of using it to create a project. Perfect timing! We had the Raspberry Pi, and now we had a purpose for it. Could we utilize the Raspberry Pi to help him determine if it was too early to rise? Kids grasp the concept of red meaning stop and green meaning go from an early age. So, we came up with an idea to construct a traffic light using the Raspberry Pi. By pushing a button, the Pi would check the day and time. If it was past 7:30 am on a Saturday, the light would turn green, signaling it was acceptable to get out of bed. However, if it was before 7:30 am, the light would turn red, indicating it was time to stay in bed. We soon realized this concept could also be applied at night. After 8 pm? Red light—stay in bed. Before 8 pm? Green light—more playtime!
With this exciting project in mind, my son and I embarked on the journey of constructing a traffic light using cardboard, a button, and three LEDs. The image above showcases our homemade traffic light creation, which brought us both joy and a valuable learning experience.
- Raspberry Pi
- Red, Green, Yellow LED
- yellow spray paint
For our traffic light project, we utilized basic materials such as cardboard, tape, and yellow spray paint to bring it to life. The traffic light itself was constructed using these materials, creating a sturdy structure. To add functionality, we incorporated red, yellow, and green LEDs, which illuminated the light in a captivating manner.
At the top of the traffic light, we positioned a small push button. This button served as the control mechanism, allowing us to activate the system and display the appropriate light based on the time. Acting as the brains of the unit, we employed a Raspberry Pi, which handled the logic and operations. To establish the necessary connections, we used wires and a breadboard, ensuring everything worked seamlessly together.
This combination of simple materials, electronic components, and the Raspberry Pi enabled us to bring our traffic light project to fruition, creating a visually appealing and interactive system.
To establish the connection between the Raspberry Pi and the three LEDs, we followed a specific wiring configuration:
- The red LED was connected to pin 18 of the Raspberry Pi, with a 100 ohm resistor placed between the LED and the ground.
- The yellow LED was connected to pin 14 of the Raspberry Pi, with a 100 ohm resistor connected in series between the LED and the ground.
- The green LED was connected to pin 15 of the Raspberry Pi, and like the others, a 100 ohm resistor was placed between the LED and the ground.
Additionally, we connected the push button to pin 4 of the Raspberry Pi, creating the necessary input for controlling the traffic light system. The other terminal of the button was connected to the ground.
By adhering to this wiring setup, we established the essential connections between the Raspberry Pi, the LEDs, and the push button, enabling the system to function as intended.