Nano NeoMatrix help

Hello,

I'm trying a normal NeoMatrix code, I'm drawing some pixels.

I have an arduino Mega and an arduino Nano.

This is the code

#include <SoftwareSerial.h>

//SoftwareSerial wifi(2,3);

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>

#include <Wire.h>
#include <RTClib.h>

#define WIDTH 36
#define HEIGHT 8
#define PIN 4

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(WIDTH, HEIGHT, PIN, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG, NEO_GRB + NEO_KHZ800);

RTC_DS1307 rtc;

#include "icons.h"
#include "numbers.h"
#include "matrix_draw_utils.h"
#include "modes.h"

Mode mode = time;

void setup() {
  Serial.begin(9600);
  //wifi.begin(9600);
  //Serial1.begin(9600);

  Wire.begin();

  //if (rtc.begin()) {
    //rtc.adjust(DateTime(__DATE__, __TIME__));
  //}

  matrix.begin();
  matrix.show();
  matrix.setBrightness(5);
}

int changeModeInterval = 75;
int changeModeCooldown = changeModeInterval;

void loop() {
  /*if (Serial.available() > 0) {
    Serial1.write(Serial.read());
  }

  String wifiData;
  while (Serial1.available() > 0) {
    char c = Serial1.read();
    wifiData += c;
  }
  if (wifiData != "") {
    Serial.print(wifiData);
  }*/

  matrix.fillScreen(0);

  if (mode == time) {
    drawIcon(CLOCK_X, CLOCK_Y, CLOCK_C, CLOCK_N, 0);
    drawTime();
    drawIcon(TIME_MODE_X, TIME_MODE_Y, TIME_MODE_C, TIME_MODE_N, 0);
  }
  else if (mode == weather) {
    drawIcon(WEATHER_MODE_X, WEATHER_MODE_Y, WEATHER_MODE_C, WEATHER_MODE_N, 0);
  }
  else if (mode == cronometer) {
    drawIcon(CRONOMETER_MODE_X, CRONOMETER_MODE_Y, CRONOMETER_MODE_C, CRONOMETER_MODE_N, 0);
  }

  if (digitalRead(3) == HIGH) {
    changeMode();
  }
  if (changeModeCooldown < changeModeInterval) {
    changeModeCooldown++;
  }

  matrix.show();
}

void changeMode() {
  if (changeModeCooldown == changeModeInterval) {
    if (mode == time) {
    mode = weather;
    }
    else if (mode == weather) {
      mode = cronometer;
    }
    else if (mode == cronometer) {
      mode = time;
    }
    changeModeCooldown = 0;
  }
}

Just center on the NeoMatrix part.
I'm using a WS2812B led lights, when I connect the data wire of the leds to the Arduino Mega PIN 4, it works perfectly.

When I do the same thing, connect it to the D4 on the Arduino Nano, it doesn't work.

Can you show how you have everything connected.

Have you tried other pins? Maybe pin 4 is dead on your Nano.

I've tried every other pin still didn't work

Connections:

Matrix+ --> External 5v+
Matrix- --> External 5v-
Matrix Data --> D4

Nano GND to Matrix GND ?

Yes, Nano GND to Matrix GND and 5v GND

Are you using a non-classic Nano? Like a Nano Every or Nano 33 IoT?

This is where I bought the nano https://articulo.mercadolibre.com.mx/MLM-603372065-arduino-nano-v30-cable-usb-_JM

I bought it yesterday

Still not working

How many pixels in your matrix?

288, I'm using a normal LED strip wired like a matrix

The problem is that on an arduino mega works perfectly

I suspect the memory issue.
Could you show other project files?

I had a RAM issue, but I converted all the const to PROGMEM

icons.h

static const int CLOCK_X[] PROGMEM = 
{
  1,2,3,4,5,6,7,8,
  0,    4,        9,
  0,    4,        9,
  0,    4,        9,
  0,    4,5,6,7,8,9,
  0,              9,
  0,              9,
  1,2,3,4,5,6,7,8,
};

static const int CLOCK_Y[] PROGMEM = 
{
  0,0,0,0,0,0,0,0,
  1,1,1,
  2,2,2,
  3,3,3,
  4,4,4,4,4,4,4,
  5,5,
  6,6,
  7,7,7,7,7,7,7,7,
};

const int CLOCK_C[] = 
{
  matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),
  matrix.Color(255, 255, 0),matrix.Color(0, 191, 255),matrix.Color(255, 255, 0),
  matrix.Color(255, 255, 0),matrix.Color(0, 191, 255),matrix.Color(255, 255, 0),
  matrix.Color(255, 255, 0),matrix.Color(0, 191, 255),matrix.Color(255, 255, 0),
  matrix.Color(255, 255, 0),matrix.Color(0, 191, 255),matrix.Color(0, 191, 255),matrix.Color(0, 191, 255),matrix.Color(0, 191, 255),matrix.Color(0, 191, 255),matrix.Color(255, 255, 0),
  matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),
  matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),
  matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),matrix.Color(255, 255, 0),
};

const int CLOCK_N PROGMEM = sizeof(CLOCK_X)/sizeof(int);

const int DOTS_X[] PROGMEM = 
{
  19,
  19,
};

const int DOTS_Y[] PROGMEM = 
{
  1,
  3,  
};

const int DOTS_C[] = 
{
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
};

const int DOTS_N PROGMEM = sizeof(DOTS_X)/sizeof(int);

const int SUNNY_X[] PROGMEM =
{
  2,3,7,8,
  0,2,3,4,5,6,7,8,10,
  2,3,4,5,6,7,8,
  2,3,4,5,6,7,8,
  0,2,3,4,5,6,7,8,10,
  2,3,7,8,
};

const int SUNNY_Y[] PROGMEM =
{
  0,0,0,0,
  2,2,2,2,2,2,2,2,2,
  3,3,3,3,3,3,3,
  4,4,4,4,4,4,4,
  5,5,5,5,5,5,5,5,5,
  7,7,7,7,
};

const int SUNNY_C[] =
{
  matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),
  matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),
  matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),
  matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),
  matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),
  matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),matrix.Color(255,255,153),
};

const int SUNNY_N PROGMEM = sizeof(SUNNY_X)/sizeof(int);

const int CLOUDY_X[] PROGMEM = {
  6,7,8,9,
  2,4,5,6,7,8,9,10,
  1,2,3,4,5,6,7,8,9,10,
  2,3,4,5,6,7,8,9,10,
  1,2,3,4,5,6,7,8,9,
};

const int CLOUDY_Y[] PROGMEM = {
  0,0,0,0,
  1,1,1,1,1,1,1,1,
  2,2,2,2,2,2,2,2,2,2,
  3,3,3,3,3,3,3,3,3,
  4,4,4,4,4,4,4,4,4,
};

const int CLOUDY_C[] = {
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
};

const int CLOUDY_N  PROGMEM= sizeof(CLOUDY_X)/sizeof(int);

const int RAINNY_X[] PROGMEM = {
  6,7,8,9,
  2,4,5,6,7,8,9,10,
  1,2,3,4,5,6,7,8,9,10,
  2,3,4,5,6,7,8,9,10,
  1,2,3,4,5,6,7,8,9,
  2,4,6,8,
  3,5,7,9,
  4,6,8,10,    
};

const int RAINNY_Y[] PROGMEM = {
  0,0,0,0,
  1,1,1,1,1,1,1,1,
  2,2,2,2,2,2,2,2,2,2,
  3,3,3,3,3,3,3,3,3,
  4,4,4,4,4,4,4,4,4,
  5,5,5,5,
  6,6,6,6,
  7,7,7,7,
};

const int RAINNY_C[] = {
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),
  matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),
  matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),matrix.Color(68, 166, 198),
};

const int RAINNY_N PROGMEM = sizeof(RAINNY_X)/sizeof(int);

const int SNOWY_X[] PROGMEM = {
  6,7,8,9,
  2,4,5,6,7,8,9,10,
  1,2,3,4,5,6,7,8,9,10,
  2,3,4,5,6,7,8,9,10,
  1,2,3,4,5,6,7,8,9,
  2,4,6,8,
  3,5,7,9,
  4,6,8,10,    
};

const int SNOWY_Y[] PROGMEM = {
  0,0,0,0,
  1,1,1,1,1,1,1,1,
  2,2,2,2,2,2,2,2,2,2,
  3,3,3,3,3,3,3,3,3,
  4,4,4,4,4,4,4,4,4,
  5,5,5,5,
  6,6,6,6,
  7,7,7,7,
};

const int SNOWY_C[] = {
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int SNOWY_N PROGMEM = sizeof(RAINNY_X)/sizeof(int);

const int TIME_MODE_X[] PROGMEM = 
{
  13,14,15,16,
  18,19,20,21,
  23,24,25,26,
};

const int TIME_MODE_Y[] PROGMEM = 
{
  6,6,6,6,
  6,6,6,6,
  6,6,6,6,
};

const int TIME_MODE_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
};

const int TIME_MODE_N PROGMEM = sizeof(TIME_MODE_X)/sizeof(int);

const int WEATHER_MODE_X[] PROGMEM = 
{
  13,14,15,16,
  18,19,20,21,
  23,24,25,26,
};

const int WEATHER_MODE_Y[] PROGMEM = 
{
  6,6,6,6,
  6,6,6,6,
  6,6,6,6,
};

const int WEATHER_MODE_C[] = 
{
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
};

const int WEATHER_MODE_N PROGMEM = sizeof(TIME_MODE_X)/sizeof(int);

const int CRONOMETER_MODE_X[] PROGMEM = 
{
  13,14,15,16,
  18,19,20,21,
  23,24,25,26,
};

const int CRONOMETER_MODE_Y[] PROGMEM = 
{
  6,6,6,6,
  6,6,6,6,
  6,6,6,6,
};

const int CRONOMETER_MODE_C[] = 
{
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),matrix.Color(128, 128, 128),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int CRONOMETER_MODE_N PROGMEM = sizeof(TIME_MODE_X)/sizeof(int);

numbers.h

const int ZERO_X[] PROGMEM = 
{
  11,12,13,
  11,13,
  11,13,
  11,13,
  11,12,13,
};

const int ZERO_Y[] PROGMEM = 
{
  0,0,0,
  1,1,
  2,2,
  3,3,
  4,4,4,
};

const int ZERO_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int ZERO_N = sizeof(ZERO_X)/sizeof(int);

const int ONE_X[] PROGMEM =
{
  12,
  11,12,
  12,
  12,
  11,12,13,  
};

const int ONE_Y[] PROGMEM = 
{
  0,
  1,1,
  2,
  3,
  4,4,4
};

const int ONE_C[] = 
{
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int ONE_N = sizeof(ONE_X)/sizeof(int);

const int TWO_X[] PROGMEM =
{
  11,12,13,
  13,
  11,12,13,
  11,
  11,12,13
};

const int TWO_Y[] PROGMEM =
{
  0,0,0,
  1,
  2,2,2,
  3,
  4,4,4,
};

const int TWO_C[] =
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int TWO_N = sizeof(TWO_X)/sizeof(int);

const int THREE_X[] PROGMEM = 
{
  11,12,13,
  13,
  11,12,13,
  13,
  11,12,13,
};

const int THREE_Y[] PROGMEM = 
{
  0,0,0,
  1,
  2,2,2,
  3,
  4,4,4,
};

const int THREE_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int THREE_N = sizeof(THREE_X)/sizeof(int);

const int FOUR_X[] PROGMEM = 
{
  11,   13,
  11,   13,
  11,12,13,
        13,
        13,
};

const int FOUR_Y[] PROGMEM = 
{
  0,0,
  1,1,
  2,2,2,
  3,
  4,
};

const int FOUR_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
};

const int FOUR_N = sizeof(FOUR_X)/sizeof(int);

const int FIVE_X[] PROGMEM = 
{

  11,12,13,
  11,
  11,12,13,
        13,
  11,12,13,
};

const int FIVE_Y[] PROGMEM = 
{
  0,0,0,
  1,
  2,2,2,
      3,
  4,4,4,
};

const int FIVE_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int FIVE_N = sizeof(FIVE_X)/sizeof(int);

const int SIX_X[] PROGMEM = 
{
  11,12,13,
  11,
  11,12,13,
  11,   13,
  11,12,13,
};

const int SIX_Y[] PROGMEM = 
{
  0,0,0,
  1,
  2,2,2,
  3  ,3,
  4,4,4,
};

const int SIX_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
};

const int SIX_N = sizeof(SIX_X)/sizeof(int);

const int SEVEN_X[] PROGMEM = 
{
  11,12,13,
        13,
        13,
        13,
        13,
};

const int SEVEN_Y[] PROGMEM = 
{
  0,0,0,
      1,
      2,
      3,
      4,
};

const int SEVEN_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
};

const int SEVEN_N = sizeof(SEVEN_X)/sizeof(int);

const int EIGHT_X[] PROGMEM = 
{
  11,12,13,
  11,   13,
  11,12,13,
  11,   13,
  11,12,13,
};

const int EIGHT_Y[] PROGMEM = 
{
  0,0,0,
  1,1,
  2,2,2,
  3,3,
  4,4,4,
};

const int EIGHT_C[] = 
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),  
};

const int EIGHT_N = sizeof(EIGHT_X)/sizeof(int);

const int NINE_X[] PROGMEM =
{
  11,12,13,
  11,   13,
  11,12,13,
        13,
  11,12,13,  
};

const int NINE_Y[] PROGMEM =
{
  0,0,0,
  1,1,
  2,2,2,
  3,
  4,4,4,
};

const int NINE_C[] =
{
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),
  matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),matrix.Color(255, 255, 255),  
};

const int NINE_N = sizeof(NINE_X)/sizeof(int);

matrix_draw_utils.h

#include <avr/pgmspace.h>

void drawIcon(int xA[] PROGMEM, int yA[] PROGMEM, int cA[], int n, int plus) {
  for (int i=0;i<n;i++) {
    int x = pgm_read_word_near(&(xA[i]));
    int y = pgm_read_word_near(&(yA[i]));
    int color = cA[i];

    matrix.drawPixel(x+plus, (uint16_t) y, (uint16_t) color);
  }
}
int i;

void drawDots() {
    int interval = 75;

    if (i >= interval) {
      drawIcon(DOTS_X, DOTS_Y, DOTS_C, DOTS_N, 0);
    }

    if (i < interval) {
      int colors[] = 
      {
        matrix.Color(0,0,0),matrix.Color(0,0,0),
      };
      drawIcon(DOTS_X, DOTS_Y, colors, DOTS_N, 0);

      if (i == 0) i = interval*2;
    }

    i--;
  }

void drawTime() {
  DateTime now = rtc.now();

  int hour = now.hour();

  String hourString = String(hour);
  char hourFirstDigit = hourString.charAt(0);
  char hourSecondDigit = hourString.charAt(1);

  if (hour < 10) {
    hourSecondDigit = hourFirstDigit;
    hourFirstDigit = '0';
  }

  switch (hourFirstDigit) {
    case '0':
      drawIcon(ZERO_X, ZERO_Y, ZERO_C, ZERO_N, 0);
      break;
    case '1':
      drawIcon(ONE_X, ONE_Y, ONE_C, ONE_N, 0);
      break;
    case '2':
      drawIcon(TWO_X, TWO_Y, TWO_C, TWO_N, 0);
      break;
    case '3':
      drawIcon(THREE_X, THREE_Y, THREE_C, THREE_N, 0); 
      break;
    case '4':
      drawIcon(FOUR_X, FOUR_Y, FOUR_C, FOUR_N, 0); 
      break;
    case '5':
      drawIcon(FIVE_X, FIVE_Y, FIVE_C, FIVE_N, 0); 
      break;
    case '6':
      drawIcon(SIX_X, SIX_Y, SIX_C, SIX_N, 0);
      break;
    case '7':
      drawIcon(SEVEN_X, SEVEN_Y, SEVEN_C, SEVEN_N, 0);
      break;
    case '8':
      drawIcon(EIGHT_X, EIGHT_Y, EIGHT_C, EIGHT_N, 0);
      break;
    case '9':
      drawIcon(NINE_X, NINE_Y, NINE_C, NINE_N, 0);
      break;
  }

  if (hourSecondDigit != NULL) {
    int plus = 4;
    switch (hourSecondDigit) {
      case '0':
        drawIcon(ZERO_X, ZERO_Y, ZERO_C, ZERO_N, plus);
        break;
      case '1':
        drawIcon(ONE_X, ONE_Y, ONE_C, ONE_N, plus);
        break;
      case '2':
        drawIcon(TWO_X, TWO_Y, TWO_C, TWO_N, plus);
        break;
      case '3':
        drawIcon(THREE_X, THREE_Y, THREE_C, THREE_N, plus); 
        break;
      case '4':
        drawIcon(FOUR_X, FOUR_Y, FOUR_C, FOUR_N, plus); 
        break;
      case '5':
        drawIcon(FIVE_X, FIVE_Y, FIVE_C, FIVE_N, plus); 
        break;       
      case '6':
        drawIcon(SIX_X, SIX_Y, SIX_C, SIX_N, plus);
        break;
      case '7':
        drawIcon(SEVEN_X, SEVEN_Y, SEVEN_C, SEVEN_N, plus);
        break;
      case '8':
        drawIcon(EIGHT_X, EIGHT_Y, EIGHT_C, EIGHT_N, plus);
        break;
      case '9':
        drawIcon(NINE_X, NINE_Y, NINE_C, NINE_N, plus);
        break; 
    }
  }

  drawDots();

  int minute = now.minute();
  String minuteString = String(minute);
  char minuteFirstDigit = minuteString.charAt(0);
  char minuteSecondDigit = minuteString.charAt(1);

  if (minute < 10) {
    minuteSecondDigit = minuteFirstDigit;
    minuteFirstDigit = '0';
  }

  switch (minuteFirstDigit) {
    case '0':
      drawIcon(ZERO_X, ZERO_Y, ZERO_C, ZERO_N, 10);
      break;
    case '1':
      drawIcon(ONE_X, ONE_Y, ONE_C, ONE_N, 10);
      break;
    case '2':
      drawIcon(TWO_X, TWO_Y, TWO_C, TWO_N, 10);
      break;
    case '3':
      drawIcon(THREE_X, THREE_Y, THREE_C, THREE_N, 10); 
      break;
    case '4':
      drawIcon(FOUR_X, FOUR_Y, FOUR_C, FOUR_N, 10); 
      break;
    case '5':
      drawIcon(FIVE_X, FIVE_Y, FIVE_C, FIVE_N, 10); 
      break;
    case '6':
      drawIcon(SIX_X, SIX_Y, SIX_C, SIX_N, 10);
      break;
    case '7':
      drawIcon(SEVEN_X, SEVEN_Y, SEVEN_C, SEVEN_N, 10);
      break;
    case '8':
      drawIcon(EIGHT_X, EIGHT_Y, EIGHT_C, EIGHT_N, 10);
      break;
    case '9':
      drawIcon(NINE_X, NINE_Y, NINE_C, NINE_N, 10);
      break;
  }

  if (minuteSecondDigit != NULL) {
    int plus = 14;
    switch (minuteSecondDigit) {
      case '0':
        drawIcon(ZERO_X, ZERO_Y, ZERO_C, ZERO_N, plus);
        break;
      case '1':
        drawIcon(ONE_X, ONE_Y, ONE_C, ONE_N, plus);
        break;
      case '2':
        drawIcon(TWO_X, TWO_Y, TWO_C, TWO_N, plus);
        break;
      case '3':
        drawIcon(THREE_X, THREE_Y, THREE_C, THREE_N, plus); 
        break;
      case '4':
        drawIcon(FOUR_X, FOUR_Y, FOUR_C, FOUR_N, plus); 
        break;
      case '5':
        drawIcon(FIVE_X, FIVE_Y, FIVE_C, FIVE_N, plus); 
        break;
      case '6':
        drawIcon(SIX_X, SIX_Y, SIX_C, SIX_N, plus);
        break;
      case '7':
        drawIcon(SEVEN_X, SEVEN_Y, SEVEN_C, SEVEN_N, plus);
        break;
      case '8':
        drawIcon(EIGHT_X, EIGHT_Y, EIGHT_C, EIGHT_N, plus);
        break;
      case '9':
        drawIcon(NINE_X, NINE_Y, NINE_C, NINE_N, plus);
        break;
    }
  }
}

void drawWeatherIcon() {
  WMO w = deserializeWmoCode(wmo.toInt());

  switch (w) {
    case SUNNY:
      drawIcon(SUNNY_X, SUNNY_Y, SUNNY_C, SUNNY_N, 0);
      break;
    case CLOUDY:
      drawIcon(CLOUDY_X, CLOUDY_Y, CLOUDY_C, CLOUDY_N, 0);
      break;
    case RAINNY:
      drawIcon(RAINNY_X, RAINNY_Y, RAINNY_C, RAINNY_N, 0);
      break;
    case SNOWY:
      drawIcon(SNOWY_X, SNOWY_Y, SNOWY_C, SNOWY_N, 0);
      break;
  }
}

void drawTemperature() {
  char temperatureFirstDigit = temperature.charAt(0);
  char temperatureSecondDigit = temperature.charAt(1);

  if (temperature.toInt() < 10) {
    temperatureSecondDigit = temperatureFirstDigit;
    temperatureFirstDigit = '0';
  }

  int firstPlus = temperatureSecondDigit == NULL ? 7 : 5;
  switch (temperatureFirstDigit) {
    case '0':
      drawIcon(ZERO_X, ZERO_Y, ZERO_C, ZERO_N, firstPlus);
      break;
    case '1':
      drawIcon(ONE_X, ONE_Y, ONE_C, ONE_N, firstPlus);
      break;
    case '2':
      drawIcon(TWO_X, TWO_Y, TWO_C, TWO_N, firstPlus);
      break;
    case '3':
      drawIcon(THREE_X, THREE_Y, THREE_C, THREE_N, firstPlus); 
      break;
    case '4':
      drawIcon(FOUR_X, FOUR_Y, FOUR_C, FOUR_N, firstPlus); 
      break;
    case '5':
      drawIcon(FIVE_X, FIVE_Y, FIVE_C, FIVE_N, firstPlus); 
      break;
    case '6':
      drawIcon(SIX_X, SIX_Y, SIX_C, SIX_N, firstPlus);
      break;
    case '7':
      drawIcon(SEVEN_X, SEVEN_Y, SEVEN_C, SEVEN_N, firstPlus);
      break;
    case '8':
      drawIcon(EIGHT_X, EIGHT_Y, EIGHT_C, EIGHT_N, firstPlus);
      break;
    case '9':
      drawIcon(NINE_X, NINE_Y, NINE_C, NINE_N, firstPlus);
      break;
  }

  if (temperatureSecondDigit != NULL) {
    int plus = 9;
    switch (temperatureSecondDigit) {
      case '0':
        drawIcon(ZERO_X, ZERO_Y, ZERO_C, ZERO_N, plus);
        break;
      case '1':
        drawIcon(ONE_X, ONE_Y, ONE_C, ONE_N, plus);
        break;
      case '2':
        drawIcon(TWO_X, TWO_Y, TWO_C, TWO_N, plus);
        break;
      case '3':
        drawIcon(THREE_X, THREE_Y, THREE_C, THREE_N, plus); 
        break;
      case '4':
        drawIcon(FOUR_X, FOUR_Y, FOUR_C, FOUR_N, plus); 
        break;
      case '5':
        drawIcon(FIVE_X, FIVE_Y, FIVE_C, FIVE_N, plus); 
        break;       
      case '6':
        drawIcon(SIX_X, SIX_Y, SIX_C, SIX_N, plus);
        break;
      case '7':
        drawIcon(SEVEN_X, SEVEN_Y, SEVEN_C, SEVEN_N, plus);
        break;
      case '8':
        drawIcon(EIGHT_X, EIGHT_Y, EIGHT_C, EIGHT_N, plus);
        break;
      case '9':
        drawIcon(NINE_X, NINE_Y, NINE_C, NINE_N, plus);
        break; 
    }
  }
}

modes.h

enum Mode {
  time, cronometer, weather
};

Not all
You have a number of icons not in PROGMEM like this:

on AVR Arduno boards all const's saved in the RAM.

If I am not miscalculated, you have about 700 bytes RAM data in your header files. If we add to this the amount of memory that is occupied by 288 neopixel leds, it turns out that the memory is occupied by about 85-90%.

So it is very likely that this is the cause of the problems.

All those const I didn't put them PROGMEM because I was getting this error variable 'CLOCK_C' with dynamic initialization put into program memory area

How can I solve this issue, by removing const?

I think you are right, I'm trying on a little sketch it works

I solved this by adding all the C[] variables into PROGMEM and converting all the colors to int value and putting them directyl like int.

Thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.