Hi,
I'm using the MAX 7219 with the LedControl Library. I'm using two ICs, one to control 8 seven segments and the second to control an 8x8 LED matrix. I'm using this arrangement to display a tachometer signal.
I know it's not recommended to use an Led matrix with more than one colour on it, but I went ahead and tried anyway.
The majority of the LEDs are white in the matrix, there are a total of 7 blue LEDs.
Now when I test the matrix (to check if the wiring is fine) by lighting up each LED one by one and leaving them on, the matrix works fine.
However when I upload the program containing the Tacho signal processing and processing for another potentiometer, three blue LEDs flicker.
If I output only these three LEDs then they don't flicker, however with the whole program there is flickering which I haven't been able to eliminate or understand.
Does the fact that all the LEDs of the LED matrix are lit all at once mean that there is no current/wiring problem?
I haven't been able to figure out if there is something in program that's causing it to flicker, so I'm pasting my code here.
Before I change the blue LEDs I just want to make sure that they are the problem.
#include "LedControl.h"
int pot=0;
unsigned long time;
volatile int count=0;
LedControl lc=LedControl(12,11,10,2);
//pin 12 is connected to the DataIn
// pin 11 is connected to the CLK
// pin 10 is connected to LOAD
unsigned long delaytime=100;
void setup() {
time=millis();
attachInterrupt(0,rpm_count,RISING);
lc.shutdown(1,false);
lc.setIntensity(1,8);
lc.clearDisplay(1);
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}
void rpm_count()
{
count=count+1;
}
void rpm_display()
{
//Calculating rpm
float no_of_revs=count;
float rpm=no_of_revs*4*60;
//Getting separate digits to display on Seven Segment
int rpm_digit4=(rpm/10000);
int rpm_digit3=(rpm/1000)-(rpm_digit4*10);
int rpm_digit2=(rpm/100)-(rpm_digit3*10)-(rpm_digit4*100);
int rpm_digit1=(rpm/10)-(rpm_digit2*10)-(rpm_digit3*100)-(rpm_digit4*1000);
int rpmint=rpm;
int rpm_digit0=rpmint%10;
//Setting the digits
lc.setDigit(0,4,rpm_digit4,false);
lc.setDigit(0,3,rpm_digit3,false);
lc.setDigit(0,2,rpm_digit2,false);
lc.setDigit(0,1,rpm_digit1,false);
lc.setDigit(0,0,rpm_digit0,false);
//Setting the led column
float rpm_led=rpm-2000.0;
rpm_led=rpm_led/11000.0;
rpm_led=rpm_led*7.0;
int rpm_led_int=rpm_led;
rpm_led_int=7-rpm_led_int;
for(int i=6;i>=rpm_led_int;i--)
{
lc.setRow(1,i,B10000001);
}
for(int j=rpm_led_int-1;j>=0;j--)
{
lc.setLed(1,j,7,false);
lc.setLed(1,j,0,false);
}
count=0;
}
void pot_display()
{
pot=analogRead(0);
float pot_float=pot/1024.0;
pot_float=pot_float*7.0;
pot_float=7.0-pot_float;
int pot_int=pot_float;
lc.setRow(1,7,B00000110);
for(int i=6;i>=pot_int;i--)
{
lc.setLed(1,i,5,true);
lc.setLed(1,i,6,true);
}
for(int j=pot_int-1;j>=0;j--)
{
lc.setLed(1,j,5,false);
lc.setLed(1,j,6,false);
}
}
void loop()
{
pot_display();
unsigned long x=millis();
unsigned long y=x-time;
if(y>=250)
{
rpm_display1();
time=millis();
}
//The problem is in these Leds:
lc.setLed(1,7,0,true);
lc.setLed(1,7,7,true);
lc.setLed(1,7,6,true);
}
Any theories?
Thanks,
Ananth