hi gang..
so I made a mockup/prototype of an LED strip... (because I couldnt find any retail ones that has he leds right next to each other instead of spaced out over 1-3 meters...etc)
soldered everything up (best I could/saw fit)...
and wired it up to my MAX7221 chip (I have MAX7219 chips.. too but if I ever jump to use SPI...might as well stick with the MAX7221's)
and gave some test code a 'go'..
now I dont have 64 leds in my matrix.. I only have 60 leds in total on this strip.. (eventually there will be another MAX7221 chip and another 60 led matrix trip/ladder.. to make a complete 'circle' totalling 2 MAX chips and 120 leds..etc
but for now..I only have 1 led strip done.. an wired up..
I am using the LedControl library posted here.. (its very easy for a beginner to understand and the functions are easy to use understand)
however.. Im sure I am not tackling this the best way..
it seems to be glitchy when it 'starts'.. and then works itself out.. but 'feels' slow or not as fast I would have though? (maybe the LedControl lib uses delays or something?)
and Im fairly certain that is NOT the right way to stop/check at 60 leds (or at 4)..when it set up for 64 leds??
maybe a different approach using the same: "lc.setLed(0,col,row,false);" type method.
for this test.. i was simple trying to turn on each led in sequence, then reverse.. (not starting from beginning and turning off, but starting from the end)
please ignore all my PRINT() statements.. Im new to coding in Arduino/C and it 'really' helps me track and debug my own code..
I commented them out.. as they make the code VERY slow.. even if you dont have the serial monitor on/displayed
//We always have to include the library
#include "LedControl.h"/*
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
***** Please set the number of devices you have *****
But the maximum default of 8 MAX72XX wil also work.
*/
LedControl lc=LedControl(12, 11, 10, 1);/* we always wait a bit between updates of the display /
unsigned long delaytime=5;
int counter1=0;
/
This time we have more than one device.
But all of them have to be initialized
individually.
*/
void setup() {
Serial.begin(9600);
//we have already set the number of devices when we created the LedControl
int devices=lc.getDeviceCount();
//Serial.println("--SET UP--");
//Serial.println(devices);//we have to init all devices in a loop
for(int address=0;address<devices;address++) {
/The MAX72XX is in power-saving mode on startup/
lc.shutdown(address,false);
/* Set the brightness to a medium values /
lc.setIntensity(address,15);
/ and clear the display */
lc.clearDisplay(address);
}
}void loop() {
//read the number cascaded devices
int devices=lc.getDeviceCount();if(counter1<60){
for(int col=0;col<8;col++) {
for(int row=0;row<8;row++) {
//for(int address=0;address<devices;address++) {
lc.setLed(0,col,row,true);
//Serial.print("DEVICE");
// Serial.println(0);
// Serial.print("SECTION ");
// Serial.println(col);
//Serial.print("LED ");
//Serial.println(row);
//Serial.println("");
delay(delaytime);
counter1++;
if(counter1 == 60){
//Serial.println("");
//Serial.println("HIT 60");
//Serial.println("");
row = 8;
//counter1=60;
}
//Serial.print("COUNTER UP: ");
//Serial.print(counter1);
//Serial.println("");
//lc.setLed(address,row,col,false);
//}
}
}
}
else if(counter1>=60){
//Serial.println("");
//Serial.println("START COUNTING DOWN");
//Serial.println("");
//we have to init all devices in a loop
for(int col=7;col>=0;col--) {
//Serial.println("COL TRACE");
for(int row=7;row>=0;row--) {
//Serial.println("ROW TRACE");//for(int address=devices;address>0;address--) {
lc.setLed(0,col,row,false);
//Serial.print("DEVICE");
//Serial.println(0);
//Serial.print("SECTION ");
//Serial.println(col);
//Serial.print("LED ");
//Serial.println(row);
//Serial.println("");
delay(delaytime);
counter1--;
if(counter1 == 4){
//Serial.println("");
//Serial.println("HIT 0");
//Serial.println("");
row = 8;
//break;
//counter1=60;
}
//Serial.print("COUNTER DOWN: ");
//Serial.print(counter1);
//Serial.println("");
//lc.setLed(address,row,col,false);
//}
}
}
}}