Parts Required
2 470 Ω resistors 4 Connection wires 2 LEDs
- Build the circuit below and remember to be very careful about how you attach the wires so that no unsheathed wires touch accidentally.
- Pay attention to the flat mark on the LED to see that it is closest to the ground.
- Notice that a single wire going from the ground plane (VSS) to the breadboard will define a complete row as ground so that both LEDs will then be connected to ground.
' {$STAMP BS2} “Command line to tell the stamp it is the BS2
Railroad: 'The label at the start of the program. Note ‘The colon after the name railroad.
LOW 0 'Turn led0 off HIGH 1 'Turn led1 on
PAUSE 200 'Hold these LEDs in these states for .2 seconds
HIGH 0 'Turn led0 on LOW 1 'Turn led1 off
PAUSE 400 'Hold LEDs in these states for .4 seconds
GOTO railroad 'Start the "railroad" loop over again
|
2 LED on the Board of EDU coming from pins 1 and 2
|
Notice on the schematic how you can attach both wires coming from the LEDs into a single common ground plane. Notice how there is an arrow coming from pin 0 and pin 1 and this indicates you are driving an output from your Basic Stamp 2.
|
Schematic for circuit
|
|
Programming the Project
Enter the program below and hit run. Does the program work? If not proceed to the section at the back of this chapter on debugging.
Your turn
- Change the timing of the lights to change the flashing of the LEDs by changing the pause cycle.
- Make one flash at twice the rate of the other.
- Program one LED to flash once for every four flashes of the other LED.
- Using multiple HIGHs and LOWs, program your LEDs to start flashing slowly and then gradually increase their rate.
|