Control LED's with the UltraBorg?

Forums:

Can LED's be controlled via the ultra board?

I've been looking for an i2c board that can control one or Ultrasound distance modules and three or four LED's.

Also, can we get the boards without the pin headers to lower the price?

Thanks!

Mike

piborg's picture

It is possible to control LEDs using the servo outputs.

What you will need to do is connect the LED and an appropriate resistor for 5V operation between the + and S pins on the servo connection.

In order to control the LED properly you will need to use the CalibrateServoPositionX calls to override the normal behaviour.
BE VERY CAREFUL DOING THIS, using these calls with a servo attached may cause permanent damage to the servo itself.

When using the CalibrateServoPositionX functions a value of 0 will be full brightness, a value of 0xFFFF will be fully off.
We can make a function to simplify things like this:

def SetLed1(brightness):
    if brightness > 1.0:
	    brightness = 1.0
	elif brightness < 0.0:
	    brightness = 0.0
    pwmLevel = 0xFFFF * (1.0 - brightness)
    UB.CalibrateServoPosition1(pwmLevel)

The same can be done for outputs 2 to 4.

The functions can be used like this:

SetLed1(1)    # Fully on
SetLed1(0.75) # 75% brightness
SetLed1(0.10) # 10% brightness
SetLed1(0)    # Fully off

Unfortunately all of the UltraBorgs we have in stock are fully assembled so we cannot sell them without the headers fitted.

Subscribe to Comments for &quot;Control LED&amp;#039;s with the UltraBorg?&quot;