I've been trying to follow a few tutorials on how to get the 7 segment to display simple output but none seem to work 100%.
It starts out fine. It increments the number across the screen and then writes 8s to all of them and then reverses. After a few loops however it starts to act weird. Here's a video link where it acts a bit weird (a few digits don't write correctly and fix themselves) and then at the end, it only displays half of the 8 digit display before it goes to 8s and crashes. https://youtu.be/LD_C7I_bGyc
Here's the code:
//We always have to include the library
#include "LedControl.h"
// pin 4 is connected to the DIN pin
// pin 2 is connected to the CLK pin
// pin 3 is connected to the CS pin
// 1 as we are only using 1 MAX7219
LedControl lc = LedControl(4, 2, 3, 1);
void setup(){
// the zero refers to the MAX7219 number, it is zero for 1 chip
lc.shutdown(0, false);// turn off power saving, enables display
lc.setIntensity(0, 0);// sets brightness (0~15 possible values)
lc.clearDisplay(0);// clear screen
}
void loop(){
// numbers 7 to 0
for (int a = 0; a < 8; a++){
lc.setDigit(0, a, a, false);
delay(100);
}
delay(1000);
// display number 8 on all segments
for (int a = 0; a < 8; a++){
lc.setDigit(0, a, 8, false);
delay(100);
}
delay(1000);
for (int a = 8; a >= 0; a--){
lc.setDigit(0, a, a, false);
delay(100);
}
}
Hardware: Arduino Uno: https://www.jaycar.com.au/duinotech-uno-r3-development-board/p/XC4410 8 digit display: https://www.jaycar.com.au/8-digit-7-segment-display-module/p/XC3714
At this stage it's hard to tell if it's a hardware issue or if it's setup related. If someone could please give me some insight or maybe run it if they have the same hardware that would be fantastic.
Thanks!
setup()
call tolc.setIntensity(0, 0)
turns the display intensity to zero, try setting it to 15.for (int a = 8; a >= 0; a--){
-- Why do you start with 8 and not with 7. The forward version go to 7a < 8;
. BTW: I enjoyed the question, because of the video. Cool Idea. ;-)