HOME

 
Basic Stamp 2
workshop
 

HARDWARE


SOFTWARE


EXAMPLES


EXTERNAL LINKS


 

Flashing LEDs with a switch

The curse

There's an old legend that tells the woeful tale of an electronics hobbyist who was experimenting with a new type of microcontroller. Once he understood the basics of the new device and its instruction set, he proceeded to write a terrific program that allowed the microcontroller to monitor the temperature of his personal computer processor...
After considering debugging, the program was ready to be entered into the microcontroller for a test run. The hobbyist burned the software into the device, plugged it into the hardware, and placed the temperature sensor in the proper place inside his computer. He then fired up the PC and sat back, admiring his new project. Everything was ready for a trial. With the flip of a switch, power was applied to the temperature sensor and, voilà, the microcontroller, with the dedicated temperature-sensing code, worked flawlessly! The LCD display came alive with the proper information, and each time the temperature changed, the display accurately indicated that change. Yes, it was a brillant effort!
The only problem seemed to be that at the instant the hobbyist activated the power switch, a dark and very dense cloud of smoke rose around the chair he was seated in. When the smoke finally cleared, he was nowhere to be found. All that was left was a few wisps from the original thick haze, rising from the chair. He had vanished - never to be seen again, alive or otherwise!
After an exhaustive, but inconclusive, investigation it was determined that the hobbyist had commited the unforgivable sin of not making his first project, regarding the new microcontroller, a light-emitting diode (LED) flasher. This unacceptable error resulted in his banishment to a as-yet-not-totally-understood place (probably floating in limbo for eternity). There was simply no other rational explanation. Other theories were proposed, but considering the legend of "the curse" associated with not flashing an LED first, these were rejected, and the case of this hobbyist's disappearance was closed forever.

Excerpt from "Guide to PICMICRO Microcontrollers", by Carl Bergquist

Schema of the circuit

Code

'{$STAMP BS2}

infiniteLoop: 'label

'if button is pressed, goto subroutine Flash
IF IN1 = 1 THEN Flash

GOTO infiniteLoop 'loop

 

Flash: 'subroutine labeled Flash

HIGH 0 'turn on LED
PAUSE 1000 'wait 1 second
LOW 0 'turn off LED
PAUSE 1000 'wait 1 second

RETURN 'go back to the rest of the program

 

top of page

vincent leclerc . v@uttermatter.com . 11-19-2003
sharerights extended to all
i am not responsible for any problems caused by suggestions made in this workshop