Hello,
I’m running the code below to drive an LED display using data published from a remove Photon. Everything runs fine for a day or two, then the display Photon locks up (i.e., it stops running through the loop function, which is supposed to blink the LED display). What’s odd is that after locking up, resetting the display Photon doesn’t fix the problem … i.e., the LEDs blink until the first remote publish command, then they freeze. Eventually, sometimes minutes or hours later, resetting the Photon works and it goes back to normal operation. The publish/subscribe functions seem to work for a while, but glitch out over time. Any ideas on what might be causing this?
Thanks!
// This #include statement was automatically added by the Particle IDE.
#include <adafruit-led-backpack.h>
#include <string>
int water_level_int = 0;
String water_level_string;
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void myHandler(String event, String data)
{
water_level_int = data.toInt();
water_level_string = data;
}
static const uint8_t PROGMEM
full1[] =
{ B01010101,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111 },
full2[] =
{ B10101010,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111 },
half_full1[] =
{ B00000000,
B00000000,
B00000000,
B01010101,
B11111111,
B11111111,
B11111111,
B11111111 },
half_full2[] =
{ B00000000,
B00000000,
B00000000,
B10101010,
B11111111,
B11111111,
B11111111,
B11111111 };
void setup() {
Serial.begin(9600);
Serial.println("8x8 LED Matrix Test");
matrix.begin(0x70); // pass in the address
Particle.subscribe("WaterLevelPublish", myHandler, ALL_DEVICES);
}
void loop() {
matrix.setRotation(0);
if (water_level_int > 8) {
matrix.clear();
matrix.drawBitmap(0, 0, full1, 8, 8, LED_ON);
matrix.writeDisplay();
delay(1000);
matrix.clear();
matrix.drawBitmap(0, 0, full2, 8, 8, LED_ON);
matrix.writeDisplay();
delay(1000);
};
if (water_level_int < 8) {
matrix.clear();
matrix.drawBitmap(0, 0, half_full1, 8, 8, LED_ON);
matrix.writeDisplay();
delay(1000);
matrix.clear();
matrix.drawBitmap(0, 0, half_full2, 8, 8, LED_ON);
matrix.writeDisplay();
delay(1000);
};
}