Skip to content

Latest commit

 

History

History
94 lines (59 loc) · 6.57 KB

reflex_subtask_4.asciidoc

File metadata and controls

94 lines (59 loc) · 6.57 KB

Sub-Task 4 will require the following components beyond what you’ve already used in the earlier sub-tasks:

  • 1 Resistor (100 ohm minimum), included in the Survival Pack

  • 5 Jumper Wires (by now, you have probably used up the jumper wire in the Survival Pack, so you’ll need to dip into the jumper wire kit recommended in [bill_of_materials])

  • 1 Pushbutton, included in the Survival Pack

  • 2 LEDs (preferably green; the Survival Pack includes 1 green LED)

Sub-Task 4 will add to the circuit you assembled for Sub-Task3 by introducing a second pushbutton component and two new LEDs to the mini breadboard. You can see these components in [Figure0401].

task0401
Figure 1. An additional pushbutton and two LEDs will be added.

Let’s build it. Insert the second pushbutton (we’ll call it PUSH2; we’ll call the one that’s already in there PUSH1) on the opposite side of the mini breadboard as shown in [Figure0402].

task0402
Figure 2. Insert the second pushbutton on the opposite side of the mini breadboard.

Now we’ll insert one LED for each player. Each LED will be placed above a pushbutton as shown in [Figure0403]. Insert each LED so that the long lead (anode) is on the row just above the pushbutton and the short lead (cathode) is on the row above that.

task0403
Figure 3. Each player will have an LED that corresponds to a pushbutton.

Now use two jumper wires to connect the cathode (short) leads from the two new LEDs to GND via pulldown resistors. The jumper wire for the Player 1 LED’s cathode (on the left, closest to the MintDuino) should go to RES2, the pulldown resistor for Button 1. The jumper wire for the Player 2 LED will go to a new 100ohm pulldown resistor (referred to as RES3) for Button 2. Insert one RES3 lead into an empty row on the mini breadboard and the other lead will go to GND where both RES1 and RES2 are connected. This can all be seen in [Figure0404].

task0404
Figure 4. Connect new LEDs to GND with a pulldown resistor.

Next you’ll connect the anode (long) lead from each LED to the ATmega chip. Connect the Player 1 (on the left side of the mini breadboard) LED to the ATmega chip with a jumper wire going to Digital Pin 5 (pin 11 on the ATmega chip). This corresponds to Row 19 on the MintDuino (only if you’ve taken care to wire it up exactly as the online instructions specify). You can plug that jumper wire into any free hole from a through e on Row 19.

Now, connect the Player 2 LED to the ATmega chip with a jumper wire going to Digital Pin 6 (pin 12 on the ATmega chip). [Figure0405] shows the two new jumper wires connecting the LEDs to the MintDuino. This corresponds to Row 20 on the MintDuino (again, only if it’s wired up exactly as in the online instructions). Plug that jumper wire into any free hole from a through e on Row 20.

task0405
Figure 5. Connect LEDs to the MintDuino with jumper wires.
Note

The jumper wires are starting to crowd the mini breadboard at this point, so feel free to move resistors and jumper wires and LEDs to other locations if you need to do so. You can also later replace the flexible jumper wires with shorter connector wires to de-clutter if necessary.

We now need to finish wiring up the Player 2 button (the Player 1 button keeps the same wiring from Sub-Task 3). Use a jumper wire to connect the bottom lead of PUSH2 to the +5V row on the bottom of the mini breadboard. Next, connect a jumper wire from the top lead of PUSH 2 to RES3 you added for the Player 2 LED. Finally, add a jumper wire (we’ll call it JUMP5) that connects RES3 (for the Player 2 LED) to Digital Pin 3 (pin 5 on the ATmega chip), which corresponds to row 13 on the MintDuino breadboard. [Figure0406] shows the circuit for Sub-Task 4 wired up and ready for its program.

task0406
Figure 6. Connect the Player 2 pushbutton to the MintDuino.

Now it’s time to program the MintDuino so that a player’s LED will light up when that player’s pushbutton is pressed. You can download the program for Sub-Task 4 at [URL here] or simply enter the code below into the Arduino IDE:

link:attachments/SubTask4_draft1.0.pde[role=include]

Upload the sketch to the MintDuino and the following will occur:

  1. Neither LED will light (at first) as each waits for its respective button to be pressed.

  2. The program will loop forever, waiting for a button to be pressed.

  3. When the Player 1 button is pressed, the state1 variable is set to HIGH.

  4. When the Player 2 button is pressed, the state2 variable is set to HIGH.

  5. If state1 is HIGH, the lightLED1 function is called.

  6. If state2 is HIGH, the lightLED2 function is called.

  7. When the lightLED1 function is called, the Player 1 LED stays lit for 1 second and then turns off.

  8. When the lightLED2 function is called, the Player 2 LED stays lit for 1 second and then turns off.

  9. The program waits for a button to be pressed again.

You’ve probably figured out that the circuit for the MintDuino Reflex Game is done. If Sub-Task 4 is working properly for you, then you’ve got all the buttons, LEDs, and resistors wired up correctly. All that’s left is to write the new sketch for the game.

Note

If one of the player LEDs is not lighting up when you press its corresponding pushbutton, check to see that the pushbutton is connected to +5 volts and that a jumper wire is connecting that pushbutton to the bottom row of the mini breadboard that is supplying the voltage. Check each pushbutton to make certain that it is connected to the proper Digital Pin on the ATmega chip with a jumper wire that is sharing a pulldown resistor going to GND. Finally, check the orientation of the player LEDs to make certain the anode and cathode leads are inserted properly – the anode leads will go to pins on the MintDuino and the cathode leads will go to pulldown resistors connected to GND.