All,
I'm not new to the forum, I rarely post but I do read the forums a lot, I have found very helpful information here many many times. I've build a large LED matrix, it's 14x150, 2100 LEDs. I have fonts working, add my own, I can update test using USBHost with USB keyboard. I switched to Arduino Due to get more memory. I'm now trying to do very basic animation, basically have a image move across the matrix in 10 LED jumps. The logic works, using printf's to check. Now I've added in the code to dynamically update the matrix. And of course it does not work. I wanted to check that the I'm building the data correct and tried printing out the Array and got 0 "zero's". I have the movement code commented out, first need to be able to display the image. I had to remove some of the Array to fit into size, see attached file.
Any suggestions ?
Thanks
/* Arduino 256 RGB LEDs Matrix Animation Frame
* Using WS2812 LED Strips
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
*/
/*
* 4H Inventors Serial Addressable LED project 2019. Arduino Due, USB Host
*
*/
#include <avr/pgmspace.h> // Needed to store stuff in Flash using PROGMEM
#include "FastLED.h" // Fastled library to control the LEDs
// How many leds are connected?
//#define NUM_LEDS 300
#define NUM_LEDS 2100
//int NUM_LEDS = 2100;
// To pad the front and back of the images
int Front_pad = 20;
int Rear_pad = 95;
int Row_count = 0;
int Row_led = 0;
int Size_image = 35;
int Image_jump = 0;
int Orig_front = 20;
int Orig_rear = 95;
// Define the Data Pin
//#define DATA_PIN 3 // Connected to the data pin of the first LED strip
#define DATA_PIN 5
// Define the array of leds
CRGB leds[NUM_LEDS];
const long rabbit2[] PROGMEM =
{
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x3f51b5, 0x3f51b5, 0x3f51b5, 0x3f51b5, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
};
// the setup routine runs once when you press reset:
void setup() {
FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS); // Init of the Fastled library
//FastLED.setBrightness(15); // orig
FastLED.setBrightness(125); //150
Serial.begin (9600);
}
// the loop routine runs over and over again forever:
void loop() {
///*
FastLED.clear();
int Row_count = 1;
//for (Image_jump = 0; (Image_jump + 20) < 150; Image_jump +10) {
for(int i = 0; i < NUM_LEDS; i++) {
Row_count = i /150; // get the number of LEDs for a row
Row_led = i % 150; // get LED number for a given row
Serial.print(" i = ");
Serial.println(i);
Serial.print("Row_count = ");
Serial.println(Row_count);
if ( (i/150) % 2 == 0){ // even "row" of LEDs
Serial.println("even row");
if ( Row_led >= Front_pad && Row_led < (Front_pad + Size_image) ) {
Serial.println("between 20 and 95");
leds[i] = pgm_read_dword(&(rabbit2[i]));
} else if ( Row_led < Front_pad) {
Serial.println("padding the Front Even");
leds[i] = 0x000000;
} else {
Serial.println("padding the Rear Even");
leds[i] = 0x000000;
}
} else { // odd row
Serial.println("odd row");
if ( Row_led >= Front_pad && Row_led < Rear_pad ) {
Serial.println("Z between 20 and 95");
leds[i] = pgm_read_dword(&(rabbit2[i]));
} else if ( Row_led < Front_pad) {
Serial.println("Row padding the Front Odd");
leds[i] = 0x000000;
} else {
Serial.println("Row padding the Rear Odd");
leds[i] = 0x000000;
}
}
} // second for loop
//============
for( int k = 0; k < NUM_LEDS; k++) {
Serial.println(" dumping Array ");
Serial.println(leds[k]);
}
//=============================
/*
Serial.println("");
Serial.print("Image_jump = ");
Serial.println(Image_jump);
if ((Image_jump + 20) < 150) {
Image_jump = Image_jump + 10;
Front_pad = Front_pad + Image_jump;
Rear_pad = Rear_pad + Image_jump;
} else {
Image_jump = 0;
Front_pad = Orig_front;
Rear_pad = Orig_rear;
}
Serial.print("Front_pad = ");
Serial.println(Front_pad);
Serial.print("Rear_pad = ");
Serial.println(Rear_pad);
Serial.print("New Image_jump = ");
Serial.println(Image_jump);
*/ // end of movement code
FastLED.show();
delay(4000);
//} //First for loop
//*/
}
test-animation.ino (8.21 KB)