SLEEP - BASIC Stamp Command Reference
calculates a correction factor that it uses during SLEEP. As a result, longer
SLEEP intervals are accurate to approximately ±1 percent.
If your application is driving loads (sourcing or sinking current through
output-high or output-low pins) during SLEEP, current will be interrupted
for about 18 ms when the BASIC Stamp wakes up every 2.3 seconds. The
reason is that the watchdog-timer reset that awakens the BASIC Stamp
also causes all of the pins to switch to input mode for approximately 18
ms. When the interpreter firmware regains control of the processor, it
restores the I/O directions dictated by your program.
If you plan to use END, NAP, or SLEEP in your programs, make sure that
your loads can tolerate these periodic power outages. The simplest
solution is often to connect resistors high or low (to +5V or ground) as
appropriate to ensure a continuing supply of current during the reset
glitch.
The demo program can be used to demonstrate the effects of the SLEEP
glitch with an LED and resistor as shown in Figure 5.41.
Demo Program (SLEEP.bs2)
' This program lights an LED and then goes to sleep. Connect an LED to pin 0 as shown in
' the description of SLEEP in the manual and run the program. The LED will turn on, then
' the BASIC Stamp will go to sleep. During sleep, the LED will remain on, but will blink
' at intervals of approximately 2.3 seconds due to the watchdog timeout and reset.
'{$STAMP BS2}
LOW 0
' Turn LED on
Snooze:
SLEEP 10
' Sleep for 10 seconds.
GOTO Snooze
Page 318 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
Vdd
470
LED
P0
'STAMP directive (specifies a BS2)
Ω
Figure 5.41: SLEEP Example LED
Circuit.
2
2
2
2
1
e
p
sx
NOTE: This is written for the BS2
but can be used for the BS1, BS2e,
BS2sx and BS2p also. Locate the
proper source code file or modify
the STAMP directive before
downloading to the BS1, BS2e,
BS2sx or BS2p.
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?