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?



Skip to comments


Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.


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.



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)


# Set LED On
pwm(d0, 100)

# wait some time for the pwm to do its ramping thing

#set LED Off
pwm(d0, 0)

# wait some time for the pwm to do its ramping thing



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


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)
$brighness = $brightness + 1

(this just ramps up, not back down).


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

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