2
\$\begingroup\$

Currently I have a project that consist in the following:

  • We have 2 USB Led lamps. (e.g 13 leds, 5V, ~200mA)

To these lamps, we would like to control the intensity of the light, through a Raspberry PI.

My main question would be what would be the simplest and cheapest way to achieve this?

So far from what I have seen in internet a digital potentiometer would work on this, maybe using a DS1669 or a AD5204.

Sorry if this question is too stupid, but I'm out of my field here, and I would like some suggestions as how to go about this. So if anyone is willing to put me in the right direction.

\$\endgroup\$
13
  • 2
    \$\begingroup\$ A schematic of the led lamps would be needed, or pictures of the pcb inside. That said, Digital pots can only be used for low current applications, current sensing, etc. More than like 10 or 20mA between the H/W/L terminals will kill the pot. They are fairly delicate compared to physical pots. They cannot directly control the leds. \$\endgroup\$
    – Passerby
    Commented May 24, 2013 at 12:34
  • \$\begingroup\$ Ha, I see thats what I thought about the digi pots. I dont have a schematics right now, since I'm still planning how to approach this. The only thing I have is the idea of a usb led lamp and all the resources of a raspberry pi, I was also thinking in a high voltage potentiometer, although that start sounding complicate to me. \$\endgroup\$
    – memo
    Commented May 24, 2013 at 12:37
  • 4
    \$\begingroup\$ A realistic approach would be to use a MOSFET as a switch, with its gate driven by a variable PWM signal generated by the RPi. \$\endgroup\$ Commented May 24, 2013 at 12:45
  • 1
    \$\begingroup\$ That's how PWM works! \$\endgroup\$ Commented May 24, 2013 at 13:00
  • 1
    \$\begingroup\$ @memo if the RPI can't do simple pwm, it wouldn't be worth the copper it's made on. It's a computer. PWM is a simple timer. It can do a ton of pwm without issue. That said, you could always use a i2c or spi PWM driver IC to offload the pwm. All the Rpi would do is tell the IC which pin to enable and at what brightness/percentage. \$\endgroup\$
    – Passerby
    Commented May 24, 2013 at 21:58

2 Answers 2

1
\$\begingroup\$

Dimming LEDs is usually done with PWM which means simply switching them on and off fast enough. If I understood correctly, you have dumb lamps connected to USB draining power directly from USB. You can not easily switch USB power on and off fast enough so you will have to plug some device between your lamp and the USB port. If you want to control it from the Raspberry Pi, you would need a circuit around some IC, a USB device driver in Linux and even more.

I guess it would be easier to use the GPIO pins of the Raspberry Pi. Those should be programmable rather easily and you would need just a very simple circuit and a software PWM for the GPIO.

\$\endgroup\$
0
\$\begingroup\$

The ATtinyX313(A) (ATtiny2313, ATtiny2313A, ATtiny4313) can be configured as a SPI, I2C, or UART slave or as a USB device with some work, and has 4 Output Compare pins available for PWM control. Simply write slave code that allows the RPi to send commands to it to change the brightness of attached LEDs via low-side NMOSFET drivers.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.