I’m a complete noob to Spark IO. I currently have built a few KA01 shields to control RGB LED strips.
The KA01 data sheet is http://www.velleman.co.uk/contents/en-uk/ka01.pdf
which says Red is on pin 3, green on 5, blue on 6.
From what I understand, the Shield Shield maps those pins to:
Red 3 -> D0
Green 5 -> D1
Blue 6 -> A7
I have the following code:
analogWrite(D0, 255);
analogWrite(D1, 0);
analogWrite(A7, 0);
But it doesn’t raise red to full brightness.
I know the KA01 works fine because when I use it on my Arduino it works perfectly.
What am I missing? Any help for a noob?
Actually, nevermind, I am seeing that the LED strip is working and being controller, but the values I pass in seem incorrect.
If I write 255 to RED, it is correct, super bright. If I then set red to 0, green to 255, it works fine, green super bright. Then if I try to set RED to 255 again, its only at 1/2 brightness.
I think there is something I am not understanding about this? When I try to do fades with more than one LED things start flickering oddly.
Might there be some incompatibility between the RGB shield and the shield/shield + spark core combo?
Just a dumb question. How do you power the Shield shield and the RGB shield?
the RGB shield has its own separate power supply.
The Shield Shield was just getting power off the USB connection to the Spark. Do I need to power the shield shield separately too? (see, dumb questions)
If you got any means to power the Shield shield directly, I’d suggest you do that. You may even use the power supply of the RGB shield on the Shield shield and have the RGB shield powered via the Shield shield.
Not sure this will do the trick, but it helps ticking off some possible reasons.
So, I ended up powering the Shield Shield with a 5A 12V supply, as well as the RGB Shield with a 5A 12V supply. Things are a bit better but still weird.
The pins map like this:
Red: Arduino pin 3, Spark pin D0
Green: Arduino pin 5, Spark pin D1
Blue: Arduino pin 6, Spark in A7
If I flash Tinker onto the Spark, and use the tinker app, I can properly set D0, D1, A7 to analogWrite and set values. Red and Blue work 100% fine. However things get funky if I set green. Namely, if everything is off (0,0,0), and I set D0 to 255 (red 100%) it works fine, then if I set green to 255, green turns on to 100% and red turns off completely. If I turn green down to 0, red comes back on, but its dimmed to like 1/2 brightness.
Other than this weird affect of green overwriting red, everything else works fine. If I keep green out of the equation, red and blue mix together properly 100% of the time.
Is this some weird interaction between D0/D1 pins?
Anything else you can think of that I can debug?
Now where the power doesn’t seem to be a problem, I’d think it should work, but since it doesn’t we are missing something.
Forget this, since you said you use Tinker One wild guess would be that you do your analogWrite()
inside loop()
with no or hardly any delay. If so, this could be the cause.
Try some other pin combinations and a different order in which you set the individual colors. Is it always one pin/one color/one position of the statement that misbehaves?
Otherwise could you post your complete code and a photo of your setup?
What kind of LEDs and how many do you use?
Does the same happen if you have no external LEDs but only the three on the board?