Hi guys,
I recently bought a cheap 7-segment MAX 7219 tube (similar to this). I wrote a simple code to test its functionality, however it doesn´t do what it should (count to 999) but show some random numbers and stops showing anything after a few seconds.
I am using ths code:
#include <LedControl.h>
LedControl lc = LedControl(8, 10, 9, 1);
unsigned long delaytime=100;
void setup() {
lc.shutdown(0, false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
Serial.begin(9600);
}
int digit(int a,int b){
lc.setDigit(0,a,b,false);
}
int digit_dp(int a,int b){
lc.setDigit(0,a,b,true);
}
void chrono() {
lc.clearDisplay(0);
int a=0;
int b=0;
int c=0;
for (int timer=0;timer<999;timer++){
a = timer % 10;
int timer1 = timer/10;
b = timer1 % 10;
int timer2=timer1/10;
c= timer2;
digit(0,c);
Serial.println(c);
delay(delaytime);
digit(1,b);
Serial.println(b);
delay(delaytime);
digit(2,a);
Serial.println(a);
delay(delaytime);
digit(3,0);
delay(500);
}
}
void loop() {
chrono();
}
(I inserted a Serial print for easier debugging).
I dont have much experience with Arduino and especially the MAX 7219 chip, so my question is: Is there anything wrong with my code? Or could the MAX 7219 7-segment tube simply be broken?
Thanks
David