PWM 6, level1, 1
PWM 7, level2, 1
PWM 6, level1, 1
PWM 7, level2, 1
PWM 6, level1, 2
PWM 7, level2, 2
' =========================================================================
'
' File...... LED_Fader.BS1
' Purpose...
' Author.... gneirynck
' E-mail....
' Started...
' Updated... 25 SEPT 2019
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL pin = B2
SYMBOL level1 = B3
SYMBOL level2 = B4
SYMBOL Led2 = 1
SYMBOL Led1 = 0
' -----[ Initialization ]--------------------------------------------------
Reset:
PINS = %00000000 ' clear all
DIRS = %00000011 ' set outputs 0 and 1
' -----[ Program Code ]----------------------------------------------------
Main:
HIGH Led1 ' Turn on LED 1
LOW Led2 ' Turn off LED 2
PAUSE 2000
' Cross-fade LED 1 to LED 2
FOR level1 = 255 TO 0 STEP -1
level2 = 255-level1
PWM Led1, level1, 2
PWM Led2, level2, 2
NEXT
' Keep LED 2 on for 3 seconds
HIGH Led2
PAUSE 3000
GOTO Main