Introduction: Reflex Test

The circuit you have built is an interactive game circuit that incorporates player input, LED indicators, and an LED chaser effect. The purpose of this circuit is to create an engaging gaming experience where players compete against each other. The game begins when a random LED turns on after a specific time period, indicating that players need to be ready to press their buttons. The player who presses their button first is declared the winner. The LED chaser circuit, controlled by the 555 timer and the 4017 decade counter, provides an additional visual effect by making three LEDs light up in a chasing pattern while the main LED is off. This adds a dynamic and visually appealing element to the game. Overall, the circuit combines player interaction, LED indicators, and the LED chaser effect to deliver an interactive and entertaining gaming experience.

Supplies

  • Raspberry Pi 3 (1) - with heatsink: The Raspberry Pi 3 is a single-board computer that serves as the central control unit for the circuit. It is recommended to have a heatsink attached to the Raspberry Pi 3. The heatsink helps dissipate heat generated by the processor, ensuring optimal performance and preventing overheating. Proper cooling is crucial, especially if the Raspberry Pi 3 will be operating for extended periods or under heavy processing load.
  • 5mm LEDs (2) - any colour: Light-emitting diodes that emit light when an electric current passes through them. In your circuit, these LEDs provide visual indicators.
  • Push Buttons (2): Momentary switches that allow users to manually trigger actions when pressed. In your circuit, these buttons are used for player input.
  • Potentiometer (1): A variable resistor with three terminals, typically used to control the voltage or current in a circuit. In your circuit, it is used to adjust parameters of the LED chaser circuit, such as the blinking speed.
  • 555 Timer IC (1): A popular integrated circuit used for generating precise timing pulses. In your circuit, it is used in astable mode to control the blinking of the main LED.
  • 4017 Decade Counter IC (1): A counter/divider IC that outputs a high signal sequentially on each of its output pins. In your circuit, it is used in conjunction with the 555 timer to create the LED chaser effect.
  • Polarized 10µF Capacitor (1): A capacitor that stores and releases electrical energy. In your circuit, it helps stabilize the voltage and smooth out any fluctuations in the power supply.
  • Nonpolarized 103 Capacitor (1): A nonpolarized capacitor typically used for filtering and noise reduction. In your circuit, it may be used to stabilize voltage or provide timing functions.
  • Solderless Breadboards (2): Platforms for building and prototyping electronic circuits without soldering. In your circuit, these breadboards are used to connect and organize the various components
  • Blue Jumper Wires (1 spool): Jumper wires with blue insulation used for making connections between components on the breadboard.
  • Red Jumper Wires (1 spool): Jumper wires with red insulation used for making connections between components on the breadboard.
  • Black Jumper Wires (1 spool): Jumper wires with black insulation used for making connections between components on the breadboard. Often used for ground connections.
  • Yellow Jumper Wires (1 spool): Jumper wires with yellow insulation used for making connections between components on the breadboard.
  • Green Jumper Wires (1 spool): Jumper wires with green insulation used for making connections between components on the breadboard.
  • 330 Ohm Resistors (2): Resistors with a resistance value of 330 ohms. These resistors are typically used in series with LEDs to limit the current flowing through them and protect them from excessive current.
  • T Cobbler Plus for Raspberry Pi 3 (1): The T Cobbler Plus is an expansion board specifically designed for Raspberry Pi 3. It provides a convenient way to connect the Raspberry Pi's GPIO pins to the breadboard, making it easier to interface with other components. The T Cobbler Plus has labeled pins that align with the Raspberry Pi's GPIO header, allowing for clean and organized connections between the Raspberry Pi and the circuit components.
  • Wire Stripper: A wire stripper is a tool used to remove insulation from the ends of wires, enabling secure connections. It is necessary for properly preparing wires before making connections in the circuit.
  • USB Keyboard and Mouse: A USB keyboard and mouse are used to interact with the Raspberry Pi and input commands.
  • HDMI Cable: An HDMI cable is required to connect the Raspberry Pi to an HDMI-compatible display, such as a monitor or TV.
  • Power Adapter - for raspberry pi 3: The power adapter is used to supply power to the Raspberry Pi and ensure its proper operation.
  • MU Python Software: MU is a user-friendly Python code editor and programming environment. It provides a simplified interface and helpful features for writing and running Python code on the Raspberry Pi. You will use MU to develop and execute the game logic for the project.

Step 1: Background Information

  • Voltage, Current, and Resistance: Gain an understanding of voltage, current, and resistance within an electrical circuit. Voltage represents the potential difference between two points, current is the flow of electric charge, and resistance restricts the flow of current. Learn Ohm's law, which states that voltage (V) equals current (I) multiplied by resistance (R). This knowledge will help you calculate current flow and voltage drops in the circuit.
  • GPIO (General Purpose Input Output): GPIO pins on the Raspberry Pi are programmable to function as either inputs or outputs. Learn how to access and control GPIO pins to interact with external components such as LEDs, push buttons, and the T Cobbler. Understand the numbering scheme of GPIO pins and how to configure them as inputs or outputs in Python programming.
  • LEDs (Light-Emitting Diodes): LEDs emit light when a current passes through them. They have a specific forward voltage (Vf) and require current-limiting resistors to prevent excessive current flow. Understand LED polarity and how to correctly connect LEDs in the circuit to allow current to flow in the forward direction.
  • Push Buttons: Push buttons are momentary switches used for player input in the game. They establish or break an electrical connection when pressed or released. Learn how to connect push buttons to the circuit and detect button presses using the Raspberry Pi's GPIO pins.
  • 555 Timer IC: The 555 timer is an integrated circuit that generates precise timing pulses. In this circuit, it operates in astable mode to control the blinking of the main LED. Gain knowledge of configuring timing components (resistors and capacitors) connected to the 555 timer to determine the on and off durations of the LED.
  • 4017 Decade Counter IC: The 4017 IC is a decade counter/divider that sequentially activates its output pins in response to clock signals. When connected to LEDs, it creates the LED chaser effect. Understand the pinout of the 4017 IC and how to connect LEDs to its output pins. Learn how the clock input and the 555 timer work together to control the LED chaser pattern.
  • Capacitors: Capacitors store and release electrical energy. In the circuit, capacitors are used for timing and noise reduction purposes. Learn about different capacitor types, such as polarized (electrolytic) and nonpolarized (ceramic, film) capacitors. Understand how to correctly connect capacitors in the circuit, considering their capacitance values and polarity for polarized capacitors.
  • Resistors: Resistors are passive components that limit the flow of electric current in a circuit. Learn about resistor values, color coding, and their role in protecting LEDs from excessive current. Understand how to calculate resistor values for current limiting and select appropriate resistors for the circuit.
  • Breadboards: Breadboards are prototyping platforms used to create temporary connections between components without soldering. Familiarize yourself with their layout, including terminal strips and a common power rail. Learn how to use jumper wires to establish connections on the breadboard, ensuring secure and organized connections.
  • T Cobbler: The T Cobbler is an interface that simplifies the connection between the Raspberry Pi's GPIO pins and a breadboard. Understand how to correctly connect the T Cobbler to the Raspberry Pi and how it facilitates easy access to GPIO pins for connecting components.
  • Python Coding Language: Python is a widely used programming language in the Raspberry Pi community. Familiarize yourself with Python syntax, data types, variables, conditionals

Step 2: Building the Circuit

  • Gather all the required components from the supply list.
  • Place the breadboard on a stable surface and ensure it is clean and free from any debris.
  • Begin by building the LED chaser circuit:

a. Connect the positive (anode) leg of the first LED to pin 3 of the 555 Timer IC through a 330-ohm resistor. Connect the negative (cathode) leg of the LED to the ground (GND) rail of the breadboard.

b. Connect the positive (anode) leg of the second LED to pin 2 of the 555 Timer IC through another 330-ohm resistor. Connect the negative (cathode) leg of the LED to the ground (GND) rail of the breadboard.

c. Repeat the process for the third LED, connecting its positive (anode) leg to pin 4 of the 555 Timer IC through a 330-ohm resistor and its negative (cathode) leg to the ground (GND) rail.

d. Connect pin 6 (threshold) of the 555 Timer IC to pin 2 (trigger) using a wire. This creates a feedback loop for the IC.

e. Connect pin 8 (VCC) of the 555 Timer IC to the positive rail of the breadboard. Connect pin 1 (ground) to the ground (GND) rail.

f. Connect pin 5 (control) of the 555 Timer IC to pin 16 (VCC) using a wire.

g. Place a polarized 10 microfarad capacitor between pin 2 (trigger) and pin 1 (ground) of the 555 Timer IC. Make sure the positive terminal of the capacitor is connected to pin 2.

h. Connect pin 3 (output) of the 555 Timer IC to pin 14 (clock) of the 4017 Decade Counter IC.

i. Connect pin 1 (clock enable) of the 4017 Decade Counter IC to the positive rail of the breadboard.

j. Connect the output pins (Q0, Q1, Q2) of the 4017 Decade Counter IC to the anodes of the corresponding LEDs. Connect the cathodes of all the LEDs to the ground (GND) rail.

  • Now, proceed with the main LED and push button circuit:

a. Connect the anode (longer leg) of the main LED to pin 4 of the Raspberry Pi via a 330-ohm resistor. Connect the cathode (shorter leg) of the LED to the ground (GND) rail.

b. Connect one terminal of each push button to a different GPIO pin on the Raspberry Pi. Connect the other terminal of each push button to the ground (GND) rail.

  • Connect the T Cobbler to the Raspberry Pi by aligning the pins and gently pressing them together.
  • Use jumper wires to establish connections between the GPIO pins of the Raspberry Pi and the respective components in the circuit. Follow the pin assignments described in the Python code section.
  • Attach the heatsink to the processor of the Raspberry Pi to ensure proper cooling during operation.
  • Finally, use the wire stripper to remove insulation from the ends of wires as needed for secure connections.

Step 3: Programming the Circuit

  1. Follow these instructions to implement the code for your LED chaser game using the Python programming language:
  2. Make sure your Raspberry Pi is powered on and connected to a display, keyboard, and mouse.
  3. Open the MU Python software on your Raspberry Pi. If you haven't installed it, refer to the provided resources or the official MU website for instructions.
  4. Create a new Python file in the MU Python editor and save it with an appropriate name.
  5. Import the required libraries at the beginning of your Python code
  6. Define the GPIO pins used for the LED and push buttons. Replace the pin numbers according to your circuit setup
  7. Create instances of the LED and Button objects using the GPIO pin numbers
  8. Prompt the user to enter the names of the left and right players
  9. Implement the game logic: Turn on the LED for a random duration between 5 and 10 seconds; Define a function to handle button press events; Assign the button press event handler to the corresponding buttons
  10. Save the Python file.
  11. Connect the Raspberry Pi to power and ensure that the circuit is properly assembled.
  12. Run the Python code by clicking the "Run" button in the MU Python editor.
  13. Observe the LED turning on for a random duration. When a button is pressed, the respective player's name will be displayed, and the LED will turn off. The LED will turn on again after another random duration when another button is pressed.

LED Chaser:

  • Using the same logic as explained above, you can create provide power to your LED chaser circuit through a free GPIO pin
  • Then define that pin as an LED and every section of teh code that mentions the main led turning on in teh form of led(on), you can simply add a line of code underneath that programs the output of the pin providing power to the LED chaser circuit to be off and vice versa
  • This will create the illusion of a loading/buffering indication which shows the user that the next round will begin shortly


Step 4: Conclusion

In this project, you have built an exciting LED chaser game circuit using a Raspberry Pi, various components, and Python programming. Let's summarize the main points and key takeaways from this project:


  • Purpose: The main purpose of the circuit is to create an interactive game where players compete against each other by pressing buttons as soon as an LED turns on. The circuit incorporates a LED chaser circuit, a main LED, push buttons, and a Raspberry Pi to provide an engaging gaming experience.
  • Key Components: The key components used in the circuit include LEDs, push buttons, resistors, capacitors, a 555 Timer IC, a 4017 Decade Counter IC, a T Cobbler GPIO breakout board, and a Raspberry Pi with a heatsink. Each component plays a vital role in controlling the timing, visual feedback, and user interaction of the game.
  • Learning Points: Throughout this project, you have gained knowledge and experience in several areas. You have learned about circuit building, using breadboards, making connections with jumper wires, understanding the functionality of various electronic components, and coding in Python using the GPIOZero library.


By successfully completing this project, you should have acquired the following skills and understanding:

  1. Circuit Construction: You have learned how to assemble a circuit on a breadboard, connect different components, and establish proper electrical connections.
  2. Component Functionality: You now understand the roles of various components such as LEDs, resistors, capacitors, and ICs in an electronic circuit and how they contribute to the overall functionality of the game.
  3. Raspberry Pi Integration: You have learned how to interface the Raspberry Pi with the circuit, utilizing its GPIO pins to control and interact with the game components.
  4. Python Programming: Through coding the game logic in Python, you have gained experience in using libraries like GPIOZero, handling button press events, controlling LEDs, and generating random timings.

The LED chaser game circuit provides an enjoyable and interactive gaming experience, testing players' reaction times and competitive spirit. It combines electronics, programming, and entertainment, making it a great project for learning and having fun with friends and family.

Feel free to experiment with different components, expand the game functionality, or modify the code to personalize the game and enhance your understanding of electronics and programming concepts. Enjoy your LED chaser game circuit and continue exploring the fascinating world of electronics and technology!