Step 29Eye fade in and out test
Here is the code for this:
' {$STAMP BS2}
' {$PBASIC 2.5}
' This program sets the brightness of the eye and fades in and the out
pwmduty VAR Byte
pwmout PIN 6 'LED connected to P6
'init
pwmduty=0 'set duty cycle to 0
runhigh:
DO WHILE pwmduty<255 'keep increasing dutycycle till 255 is reached
PWM PWMout, pwmduty,15 ' run to increase voltage to LED decrease last # for faster
pwmduty=pwmduty+1 'Increase duty cycle by 1
LOOP
runlow:
IF pwmduty>=255 THEN pwmduty=254 'set duty cycle to 254
DO WHILE pwmduty >=1 'continue to decrease voltage to LED
PWM pwmout,pwmduty,25 ' run to decrease voltage to LED increase last # for faster
pwmduty=pwmduty-1 'Decrease cycle by 1
LOOP
PAUSE 2000
GOTO runhigh 'start over
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|
































































































