- Create a program with four different labels and GOTO statements that will execute one after the other. In this process, develop different light patterns for each subroutine.
- Show your patterns to the class.
Now that you feel comfortable in using binary and the OUTs command to define the high and low values of the pins, in this section you will be adding a switch and using conditional IF THEN statements to allow two separate sequences of LED programming to happen in based on the switch. | Circuit with switc. Don't forget the 10k Ohm resistor also attached to the switch |
| Back side of circuit without push-button switch for clarification |
Programming the project ' {$STAMP BS2} ' {$PBASIC 2.5} Led VAR Byte OUTPUT 15 Start: FOR led = 0 TO 7 HIGH led PAUSE 100 LOW led NEXT IF (IN15 = 1) THEN change GOTO start Change: FOR led = 7 TO 0 HIGH led PAUSE 100 LOW led NEXT IF (IN15 = 1) THEN start GOTO change Download the code. Notice how in order to change the direction of the LEDs that you must hit the button at just the right moment.
|