Hello,
I am having a problem I can't figure out. I have a bunch of arrays that I am using to set neopixels into letters.
I have all 26 letters as arrays, which I am trying to pass into a function that makes the letters.
What happens here is that if I pass one array as an argument into the function, it works fine. If I have one array followed by another, the program locks up and nothing happens. I've had a few people look at this
I am doing this on a Gemma, but I'm not getting any errors regarding memory usage.
The code below should form an 'A', wait two seconds, then form a 'B' - but it doesn't. It works fine if I comment out the second letter. The code compiles fine in both cases. Any ideas?
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 1
#define NUMPIXELS 63
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
const int buttonPin = 0; // the number of the pushbutton pin
int buttonState = 0;
int delayval = 1; // delay for half a second
//letters
int let_a[] = {0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1};
int let_b[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0};
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (AVR_ATtiny85)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
letter(let_a);
delay(2000);
letter(let_b);// if you comment this line out, it works.
}
else {
shutOff();
}
}
void letter(int array[])
{
for (int i = 0; i < NUMPIXELS; i++) {
if (array == 1) {
- pixels.setPixelColor(i, pixels.Color(255, 0, 0));*
- pixels.show();*
- delay(delayval);*
- }*
- else {*
- pixels.setPixelColor(i, pixels.Color(0, 0, 0)); // off*
- pixels.show();*
- }*
- }*
}
void shutOff()
{ - for (int i = NUMPIXELS; i >= 0; i--) {*
- // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255*
- pixels.setPixelColor(i, pixels.Color(0, 0, 0));*
- pixels.show();*
- //delay(10);*
- }*
}