0

I'm not that experienced with electronics but I am learning. And I've set a challenge for myself. I have a Digispark USB Development board (and many more but I want to use this one!), I have a Bluetooth module and I have two RGB LEDs which I want to control over the Bluetooth connection. Each LED has to be controlled separately and I want to be able to set each color separately and be able to mix about 256x256x256 colors. Which means, PWM connections. The Bluetooth connection would listen to instructions, receiving four bytes containing RGB values and a value between 0 and three to pick which light needs to be set. (0=None, 1=left, 2=right, 3=both)
Also important is that it needs to be small. It will end up in a container of of roughly 3x3x10 CM in size. (Slightly bigger than 1x1x3 inch.)

The challenge is that Digispark only has 6 pins available so that's not enough to handle this all. I could use three pins and use a 74HC165N Shift Register but that would just turn each color on or off, thus limiting me to 8 colors. That's not good enough! Besides, I also need to connect the four pins of the Bluetooth module.

So my question is simple: What would I need more to build this project? To send the proper six analog signals while having enough pins to handle the Bluetooth datastream?

1
  • The function of this device is to display warning signals from a web server nearby. These warning signals are color-coded and relate to two different domains on the server. One light per server. Per server there are about 30 different errors, each with their own admin-defined color. Exact protocols are still under development since I first want to see the device working before I start on the related code. (I'm more a coder anyways.) Commented Oct 25, 2015 at 21:53

1 Answer 1

1

Which means, analog connections.

Nope. It means PWM.

How would you control the brightness of a single LED?

By generating a PWM signal with:

  • sufficiently high frequency to not be able to notice the flickering;

  • duty cycle proportional to the brightness you want/need, where 100% is full brightness, and 0% is OFF

You only have to do that for each colour of the RGB LED you want to drive. Ideally you would use a HW block capable of generating the PWM signal, but it can be also bit-banged, should you run out of PWM blocks.

Just keep in mind that different colours have different currents (for the same level of brightness), so you have to pay attention at calculating the correct value of the resistor applied to each colour.

If you prefer to ensure that each channel is driven by a HW PWM generator, you can also use an external driver. Ex: I2C 6-channels PWM generator.

5
  • PWM, not analog. Noted. I keep making that mistake. The calculations for the resistors won't be too complex. It doesn't have to be perfect either. The challenge is mostly finding the right part to use and to know how to use that part from the sketch. Commented Oct 25, 2015 at 21:45
  • 1
    To be fair, the Arduino library calls it Analog, but you do get an analog value only after passing through a low pass filter. I linked what I think is the right part. Did you have a look at it? To know how to program it, you need to check its datasheet. Investing in a Bus Pirate[1] might be worth considering, to decouple the I2C programming with the PWM programming. [1]: dangerousprototypes.com/docs/Bus_Pirate Commented Oct 25, 2015 at 21:51
  • Yes, I checked the part but I can't any distributor in Europe who sells these. Another challenge will be connecting it to my other hardware. Soldering is not my strongest point. Found a shop in my area that sells a Bus Pirate but it takes three weeks before it's back in stock. And that's the most annoying part: waiting for things to become available somewhere. Commented Oct 26, 2015 at 17:22
  • 1
    You can use the extra time practicing soldering ;-) Commented Oct 26, 2015 at 17:40
  • Well, I'm not in a hurry anyways. :) Plenty of other projects that I want to do first. Most of them coding-related but this project would have been nice to combine coding and electronics. :) Commented Oct 27, 2015 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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