Asked — Edited
Resolved Resolved by DJ Sures!

Is It Possible To Ramp Up And Down The Brightness Of Leds?

No lucking finding a post on this. I am working on a BB-8 driod with the EZ-Robot and am looking to get LEDs to quickly ramp to full brightness and fade out the same way (as opposed to just turn on or off.) Any ideas on the best way to achieve this?

Thanks,

Bob


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

#1  

Yes, you can use PWM to control the brightness of an LED, so a script that ramps up and down the pwm going to the digital port will do it.

Alan

PRO
Synthiam
#2  

Use the ServoSpeed() command to apply a ramping speed to the PWM. And as alan mentioned, use the PWM command to set the brightness.

Something like this...



# set the servo speed to 2
ServoSpeed(d0, 2)

:loop

# Set LED On
pwm(d0, 100)

# wait some time for the pwm to do its ramping thing
sleep(3000)

#set LED Off
pwm(d0, 0)

# wait some time for the pwm to do its ramping thing
sleep(3000)

goto(loop)


#3  

I figured it might be through the servo controller. Seeing the code is very helpful. Thanks for the fast response, guys!

#4  

Oh, good one DJ. I didn't think about using the PWM ramping built into Servospeed.

I did this script (D11 is my LED)


$brightness = 0
repeatwhile($brightness) <= 100)
  PWM(D11,$brightness)
$brighness = $brightness + 1
Sleep(150)
endrepeatwhile

(this just ramps up, not back down).

#5  

@Science Bob.... Next time ask us something really challenging will ya.... LOL

Welcome to ez robot, btw.... :)