Joined
·
5,858 Posts
Ok, so I'm trying to use the basic stamp PWM command to fade on a pair of LED eyes, hold it on for 8 seconds, fade them down and hold them off for 8 seconds. Here is the code I have come up with:
The snag I've hit is that the LEDs fade on, but then never fade off. Through the use of the debug lines in there, I can tell the program is executing beyond the "HIGH eyes" command, but for some reason the eyes are not fading out.
Any ideas?
Code:
' {$STAMP BS1}
' {$PBASIC 1.0}
' =========================================================================
'
' © 2006 Unpleasant Street
' File....... LEDFader.bs1
' Purpose.... Fade an LED on and off
' Author..... David Lindblom
' E-mail..... [email protected]
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
'
' This is a PROP-1 program designed to fade an LED on and off using
' persistance of vision to trick the eye into thinking the LED is fading
' on and then off.
' -----[ Revision History ]------------------------------------------------
'
' LEDFader.bs1 - January 29, 2007 - First version.
' -----[ I/O Definitions ]-------------------------------------------------
'
SYMBOL eyes = PIN0 ' Pin assigned to Gargoyle's eyes
' -----[ Constants ]-------------------------------------------------------
'
SYMBOL No = 0
SYMBOL Yes = 1
' -----[ Variables ]-------------------------------------------------------
'
SYMBOL level = B1 ' Brightness level
' -----[ Initialization ]--------------------------------------------------
'
Reset:
' 76543210 ' bit positions
DIRS = %11111111 ' make P7 - P0 outputs
PINS = %00000000 ' P7 - P0 off
' -----[ Program Code ]----------------------------------------------------
'
' We start each cycle up here.
' We will come here after every run of the program.
Main:
' Fade eyes on
FOR level = 0 TO 250 STEP 5
PWM eyes, level, 8
NEXT
' Eyes on
HIGH eyes
PAUSE 8000
DEBUG "What is going on here?"
' Fade eyes off
FOR level = 255 TO 0 STEP -5
PWM eyes, level, 8
NEXT
' Eyes off
LOW eyes
PAUSE 8000
DEBUG "I have no idea what is going on."
' Back to the top
GOTO Main
Any ideas?