Author Topic: BS2: RGB LED Fade w/ PWM  (Read 3124 times)

Offline FOOKz™

  • Hardware Modder
  • Research & Development
  • E = MC² Mad Scientist
  • *
  • Posts: 2070
  • Post quality +37/-2
  • Electronics Expert Electrical Engineer
BS2: RGB LED Fade w/ PWM
« 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

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]

« Last Edit: December 22, 2010, 10:36:24 PM by FOOKz »

Follow my Instagram and subscribe to my YouTube

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal