I am new to arduino and have a sparkfun pro micro that I'm using to power a one meter (60 pixels) APA 102 strip. I currently power it via USB and have a program that sends lighting instructions to it. I can only seem to power ~15 pixels with full range of brightness and ~30 if I keep the brightness at about half.
Anything more and the pro micro will stop recieving data and either freeze at the last color it's recieved or turn a bright red (which I assume is a visual indication of the fail because I didn't code that). At this point, the COM port will also become inaccessible until the code is either re-uploaded or in some cases, I simply disconnect the strip. This leads me to believe that the amount of power that I am demanding is too much for the board to put out.
So am I right in this assumption? and If so, what can I do to increase the amount of pixels I can power at full range?
I'll also post my code below in case there is something I can do there to increase the pixel amount:
#include <Adafruit_DotStar.h>
#include <SPI.h>
#define NUMPIXELS 60
#define DATAPIN 4
#define CLOCKPIN 5
Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);
// Variables
int mode;
int numColors;
int fadeSpeed;
int BBCC;
int R;
int G;
int B;
int Bright;
void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
strip.begin(); // Initialize pins for output
strip.show(); // Turn all LEDs off ASAP
}
int head = 0, tail = -10; // Index of first 'on' and 'off' pixels
uint32_t color = 0xFFFFFF; // 'On' color (starts red)
void loop() {
//strip.setPixelColor(head, color); // 'On' pixel at head
//strip.setPixelColor(tail, 0); // 'Off' pixel at tail
strip.show(); // Refresh strip
delay(20); // Pause 20 milliseconds (~50 FPS)
getData();
if (mode == 1)
{
for (int i = 0; i < (60); i++)
{
if (i % 2 == 0)
strip.setPixelColor(i, G, R, B);
}
strip.setBrightness(Bright);
strip.show();
}
else
{
for (int i = 0; i < (60); i++)
{
if (i % 2 == 0)
strip.setPixelColor(i, 150, 200, 40);
}
strip.setBrightness(255);
strip.show();
}
}
int readLine(int readch, char * buffer, int len)
{
static int pos = 0;
int rpos;
if (readch > 0)
{
switch(readch)
{
case '\r':
{
break;
}
case '\n':
{
rpos = pos;
pos = 0;
return rpos;
}
default:
{
if (pos < len-1)
{
buffer[pos++] = readch;
buffer[pos] = 0;
}
}
}
return 0;
}
}
void getData()
{
char buf[80];
bool redo = true;
if(readLine(Serial.read(), buf, 80) > 0)
{
int i = 0;
int j = 0;
bool skip = false;
char fin[3];
if (skip == false)
{
do// mode
{
switch (buf[i])
{
case '\n':
{
skip = true;
redo = false;
break;
}
case '|':
{
mode = atoi(fin);
//Serial.print(mode);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
if (skip == false)
{
do// number of colors
{
switch (buf[i])
{
case '\n':
{
skip = true;
redo = false;
break;
}
case '|':
{
numColors = atoi(fin);
//Serial.print(numColors);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
if (skip == false)
{
do//
{
switch (buf[i])
{
case '\n':
{
skip = true;
redo = false;
break;
}
case '|':
{
fadeSpeed = atoi(fin);
//Serial.print(fadeSpeed);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
if (skip == false)
{
do
{
switch (buf[i])
{
case '\n':
{
skip = true;
redo = false;
break;
}
case '|':
{
BBCC = atoi(fin);
//Serial.print(BBCC);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
if (skip == false)
{
do
{
switch (buf[i])
{
case '\n':
{
skip = true;
redo = false;
break;
}
case '|':
{
R = atoi(fin);
//Serial.print(R);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
if (skip == false)
{
do
{
switch (buf[i])
{
case '\n':
{
skip = true;
redo = false;
break;
}
case '|':
{
G = atoi(fin);
//Serial.print(G);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
if (skip == false)
{
do
{
switch (buf[i])
{
case '\n':
{
skip = true;
redo = false;
break;
}
case '|':
{
B = atoi(fin);
//Serial.print(B);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
if (skip == false)
{
do
{
switch (buf[i])
{
case '\n':
{
Bright = atoi(fin);
//Serial.println(Bright);
i++;
redo = false;
break;
}
default:
{
fin[j] = buf[i];
i++;
break;
}
}
j++;
}while(redo);
redo = true;
j = 0;
}
}
}