Acidmods

AcidMods Resources ----- ( These are helpful tools for modding ) => Open Source Code & AcidMods Free Code => Topic started by: FOOKz™ on December 22, 2010, 09:50:22 PM

Title: BS2: RGB LED Fade w/ PWM
Post by: FOOKz™ on December 22, 2010, 09:50:22 PM
I built this with Basic Stamp, i thought it was cool so i'm sharing.

RGB LED PWM (http://www.youtube.com/watch?v=cZmrvFnT5hE#)

This is pretty net, LED fade speed controlled by two variables.
Basic Stamp does not support *.hex files
'PBASIC' is the programming language used to code this

Code:
[spoiler]
' {$STAMP BS2}
' {$PBASIC 2.5}

HIGH 15
HIGH 14
HIGH 13
PAUSE 1
LOW 15
LOW 14
LOW 13

pulse     VAR Word
time_pwm  VAR Word

time_pwm = 350
pulse = 1 / 2

DO

DO UNTIL pulse = time_pwm
 PULSOUT 15, pulse
 pulse = pulse + 1
LOOP

DO UNTIL pulse = 1
 PULSOUT 15, pulse
 pulse = pulse - 1
LOOP

PAUSE 2

DO UNTIL pulse = time_pwm
 PULSOUT 14, pulse
 pulse = pulse + 1
LOOP

DO UNTIL pulse = 1
 PULSOUT 14, pulse
 pulse = pulse - 1
LOOP

PAUSE 2

DO UNTIL pulse = time_pwm
 PULSOUT 13, pulse
 pulse = pulse + 1
LOOP

DO UNTIL pulse = 1
 PULSOUT 13, pulse
 pulse = pulse - 1
LOOP

PAUSE 2

DO UNTIL pulse = time_pwm
 PULSOUT 14, pulse
 pulse = pulse + 1
LOOP

DO UNTIL pulse = 1
 PULSOUT 14, pulse
 pulse = pulse - 1
LOOP

PAUSE 2

LOOP
[/spoiler]

(https://acidmods.com/forum/proxy.php?request=http%3A%2F%2Fi214.photobucket.com%2Falbums%2Fcc123%2Fsnoodracoon1%2F90b10e4a.png&hash=a07bcadb19889b9c0c6c2af1188dfa5bf1549954)
SimplePortal 2.3.5 © 2008-2012, SimplePortal