Strange behavior with setRGBled

We already know that an ADC input has a high enough impedance and low enough leakage current that external noise can be picked up by an unconnected pin. That’s why reading an unconnected ADC pin is often used to seed a random number generator. From the Arduino randomSeed() documentation:

If it is important for a sequence of values generated by random() to
differ, on subsequent executions of a sketch, use randomSeed() to
initialize the random number generator with a fairly random input, such
as analogRead() on an unconnected pin.

Unless the reverse leakage through the LED is fairly high, and thus the impedance fairly low, I think external noise will still swamp any attempts at getting a meaningful DC reading, especially if someone’s finger is close to the input.

However, I’ve realised that the ADC is of the sample and hold type. It has a resistor (specified to be between 1K and 100K ohms) between the pin and the ADC sample/hold capacitor (which is about 14pF). This could be used as an RC filter to smooth out a high frequency PWM signal. If this PWM signal were generated on the red LED pin, it might make it through the blue LED’s capacitance and present a fairly stable specific reading on the green pin ADC, in the case of a reversed RGB LED.

So what would have to be done is:

  1. Reprogram timer 0 or timer 1 to produce a high frequency PWM signal, with a high percentage low duty cycle, on the green LED pin.
  • Take an ADC reading on the red LED pin, using a long integration time so the voltage on the S/H capacitor will stabilise.

  • Once the reading (or multiple readings for better confirmation) is taken. The timer is reset to its original configuration.

  • If the RGB LED is reversed, the ADC reading will be a low value, close to the duty cycle of the PWM output, which was coupled through the capacitance of the blue LED. If the RGB LED is correct, the ADC reading will be clamped to above Vcc-1.8V by the red LED, which has its other lead tied to Vcc.

All of this would have to be done by direct control of the hardware. I doubt that any standard Arduino functions would be suitable.

I don’t really have the time or interest to work on this at the moment, but you or someone else is welcome to have a go.

Your thoughts and input are welcome!

One additional factor - we’re working on the red LED here. At the same time, program the blue LED (or the “other” LED, such as it is) to be fully on.

This will maximize the ambient light, and it will be high energy blue light in the case we are considering. Ambient high-energy light will maximize the reverse current in the other LED, driving us more to the case we are interested in exploring.

Although I realize it has a low chance of success, I may give the fully static scenario a try, as I think it is easier to set up than the AC coupled case. If I can distribute the code, we can get some statistics from deployed Arduboys to see what happens out there.

This is disappointing, but not much can be done I guess. :frowning:

The opposite approach has been taken: Remove the tunes code so that the timers are usable by the RGB LED with PWM. If you want sound, you can use ArduboyTones, which doesn’t interfere with the RGB LED.

Also, my Arduboy2 library has a digitalWriteRGB() function, if you want to control the RGB LED using standard digital I/O instead of PWM.

I didn’t even realize that an RGB led was installed, haha! Upon running the above mentioned code, I also can confirm that I only have Red and Blue. If I could be adventurous I may have a go at rotating the SMD, but I think I won’t bother. For one colour, I will just purchase the next model, with more improved features :slight_smile: Good job guys, I still love this thing even if it’s 1/3 the colour down!

1 Like

I didn’t know it had an LED until this thread, I did assume mine didn’t work, but running the test it does actually work correctly. It’s so bright though I can’t imagine using it for much. If someone is playing at night they are going to be blinded!

1 Like

It doesn’t have to be run at full brightness. Using the setRGBled() function, the brightness of each LED can be set anywhere between off and fully on.

I’m looking forward to people incorporating the led in a game somehow.

As for what I will be trying with them, I want to take the arduboy controller code and add a light for every time you click the button. It’s just a fun programming goal I set for myself.

1 Like

Has there been any follow up on this?

The pre-order lower price will expire soon, and since I have five wrong-LED Arduboys, it would be nice if I could apply those discounts to a pre-order unit with the correct LED.

I think we might decrease the brightness in our next batch, but it was intended to be very attention grabbing. If it’s flashing RGB (Sorry!!!) then it grabs a lot of attention at maker faire and such.

Reach us via the contact form and let us know specifically you would like to grab the store credit.

You might also wish to look into balancing the brightness of each LED. I know it’s cheaper and easier to use the same dropping resistor value for all 3 LEDs but the current required for a given (apparent) brightness and the voltage drop on each LED varies, thus requiring a different resistor value for each.

For instance, on my home made system I found a good balance by running at about 3.2mA for red, 2.3mA for blue, and only 0.8mA for green. On a real Arduboy with a fully charged battery, I’ve measured 8.6mA for red, 4.8mA for blue and 5.2mA for green. The RGB LED I’m using is a different part but the characteristics will be similar.

Good point, I’ve also noticed that because the value of the resistor probably high enough, it’s difficult to get a dim glow. Increasing the value should hopefully give a more linear brightness range.

1 Like

I submitted a request for the store credit through the contact form on Aug 18, and got a reply from Celine on Aug 19 that they would, “check in with the store back-end, and I will email you back with more information”. It’s been 5 weeks and no further communication.

Any help, Kevin?

I have to say I got my Arduboy yesterday. And it works perfectly i have used all of your led testing codes (no need to reinvent the wheel) I have no issues with the led. I have a green Arduboy if that matters.

1 Like

All of the pre-orders have their LEDs properly installed… Something which caused the units to arrive a little later then expected. :wink: