• Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo.

Tengo un pequeño problema

Tengo un pequeño problema Publicado por Paco

Posted 4 meses 3 semanas antes #2125
Hola buenos días, he generado un código Arduino para manejar 2 paneles leds de 32x8 , pero no consigo que se ilumine el segundo panel, el primero está correcto pero cuando a ese mismo panel cambio el pin de salida de Arduino no se enciende, alguien me podría ayudar si ven algún error en el código muchas gracias.

El código es:

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

// DATA PINS

#define DATA_PIN_PANEL1 8
#define DATA_PIN_PANEL2 9

#define arr_len( x )  ( sizeof( x ) / sizeof( *x ) )

// Matrix setup params
Adafruit_NeoMatrix matrix1 = Adafruit_NeoMatrix(32, 8, DATA_PIN_PANEL1,
NEO_MATRIX_TOP    + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE + NEO_MATRIX_ZIGZAG,
NEO_GRB            + NEO_KHZ800);

Adafruit_NeoMatrix matrix2 = Adafruit_NeoMatrix(32, 8, DATA_PIN_PANEL2,
NEO_MATRIX_TOP    + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE + NEO_MATRIX_ZIGZAG,
NEO_GRB            + NEO_KHZ800);

// Edit this
// The important stuff, your message and colors

char* Text1[] = {"PRUEBA 1"};
char* Text2[] = {"PRUEBA 2"};
const uint16_t colors1[] = {matrix1.Color(255, 215, 0)};
const uint16_t colors2[] = {matrix2.Color(255, 0, 255)};
int brightness = 60;
// End Edit

int numMode1 = arr_len(Text1) - 1;
int numMode2 = arr_len(Text2) - 1;
int numColor1 = arr_len(colors1) - 1;
int numColor2 = arr_len(colors2) - 1;
int pixelPerChar = 4;
int maxDisplacement1;
int maxDisplacement2;
int mode1 = 0;
int mode2 = 0;

void setup() {
  matrix1.begin();
  matrix1.setTextWrap(false);
  matrix1.setBrightness(brightness);
  matrix1.setTextColor(colors1[0]);

  matrix2.begin();
  matrix2.setTextWrap(false);
  matrix2.setBrightness(brightness);
  matrix2.setTextColor(colors2[0]);
}

int y1 = matrix1.height();
int x1 = matrix1.width();
int pass1 = 0;
int line_pass1 = 0;

int y2 = matrix2.height();
int x2 = matrix2.width();
int pass2 = 0;
int line_pass2 = 0;

void loop() {
  // if mode greater than numMode reset
  if (mode1 > numMode1) {
    mode1 = 0;
  }
  if (mode2 > numMode2) {
    mode2 = 0;
  }

  matrix1.fillScreen(0);
  matrix2.fillScreen(0);

  matrix1.setCursor(x1, 0);
  matrix2.setCursor(x2, 0);

  scroll(&matrix1, Text1[mode1], 10, x1);
  scroll(&matrix2, Text2[mode2], 10, x2);
}

// this does the magic of scrolling
void scroll(Adafruit_NeoMatrix* matrix, char* message, int delays, int &x) {
  int maxDisplacement = strlen(message) * pixelPerChar + matrix->width();
  if (++line_pass1 > matrix->width()) line_pass1 = 0;
  matrix->print(String(message));
  if (--x < -maxDisplacement) {
    x = matrix->width();
    if (++pass1 >= numColor1) {
      pass1 = 0;
    };
    matrix->setTextColor(colors1[pass1]);
    mode1++;
  }
  matrix->show();
  delay(100);
}
Post by Paco

Por favor, Conectar o Crear cuenta para unirse a la conversación.

Tiempo de carga de la página: 0.822 segundos