PiGlow on Arduino - what am I doing wrong?


Hi. I’m trying Gadgetoid’s Arduino library on a Nano, which I’m coding in the Arduino IDE 1.6.9. However I’m having some issues. I’m a total novice at C - and pretty new to Arduinos generally, so it’s entirely possible I’ve just done something dumb. But I could do with some pointers please.

Firstly - I couldn’t get the sample code to compile without editing. In the PiGlow.h file the compiler was objecting to lines 16 to 18 where the leg arrays are defined;

leg0 = { 6, 7, 8, 5, 4, 9 } ;
leg1 = { 17, 16, 15, 13, 11, 10 } ;
leg2 = { 0, 1, 2, 3, 14, 12 } ;

…which gave the compiler error “error: assigning to an array from an initializer list”. But changing it to the following did allow it to compile.

int leg0[6] = { 6, 7, 8, 5, 4, 9 } ;
int leg1[6] = { 17, 16, 15, 13, 11, 10 } ;
int leg2[6] = { 0, 1, 2, 3, 14, 12 } ;

That may have been inappropriate, since - like I said I don’t know C well at all. And when that’s uploaded to the Arduino, all that happens is that the bottom left, red, LED on the PiGlow flickers. Just that one light.

Any idea why?



I reckon it’s a power related issue… how did you wire the piglow to the nano?


It’s wired as per the directions on the Git page - and connected using solder-less breadboard, powered with a breadboard power supply (https://www.amazon.co.uk/gp/product/B00YUY8KLI/).


OK, I thought you might have only one 3.3V line connected.

To clarify though, the nano and piglow are powered from the same source right? I ask because for i2c to work properly the slave and master have to share the same ground line.


Both the PiGlow & Nano are powered by the same breadboard PSU. But there are two feeds from that particular PSU (left & right, each either 3.3V or 5V). It’s plausible I’ve used a ground line from each of the two sides. I’ll make sure I’ve got a single, common ground in use. Thank you.


Hmm … No that wasn’t it. The nano & PiGlow are sharing a common ground.


I tried with a Uno board today and I can confirm that the demo sketch is not working as intended (well, I wouldn’t think that the intention is the pulse on a single LED you see).

try the following example, which, while unspectacular, should work as a test:

#include <Wire.h>
#include "PiGlow.h"
#define BRIGHTNESS 50

PiGlow piglow;

void setup() {

void loop() {
for(int pin = 0;pin<18;pin++){


other than that, the leg and ring methods as defined by the library don’t seem to work currently… I don’t think that has to do with the leg0-2 arrays initialisation as you corrected, that looks good to me, though I’m no authority in C either.


I think I see the problem, the values are purged out of the array when they are declared as private.

… I’ve got it working now, though I need @gadgetoid to review the PR, I have a sneaking feeling that it’s not the proper way to fix PiGlow.h


sorry, just realised I didn’t leave a link to the pull request I alluded to:


Great, thanks. Yes I can light up all 3 legs of the PiGlow now. Hopefully Gadgetoid will find find time to update the library - inc. its other methods. Cheers 😀