It’s been a while since I last played with Arduino. Well, now that my 7-segment displays have arrived (and it’s getting too hot for me outside): playtime! Rather than buying pre-configured sets, I wanted to get back to the ‘basics’ to better understand how this works by bringing all components together myself.
Later on I want to integrate this logic in my cockpit.
Basic test consists of performing a count from 1-999, increase by one each 1/10s, pauze at 999, restart at 0. Initial value during startup 321.
Spoiler alert: utterly boring video!!
/* Count from 1-999, increase by one each 1/10s. Initial value set to 321. The circuit: - MAX7219 CLK -> Arduino PIN 13 - MAX7219 DIN -> Arduino PIN 11 - MAX7219 CS (Load) -> Arduino PIN 10 - MAX7219 Power -> Arduino 5V - MAX7219 GND -> Arduino GND - MAX7219 general wiring: https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf (Note: used 3 x 10KOhm resistors in series between 5V and MAX7219 PIN 18 (ISET) Created 2019/06/02 By Maarten Van Damme Modified By Maarten Van Damme http://projects.familievandamme.be Based on: https://Brainy-Bits.com */ #include "LedControl.h" LedControl lc = LedControl(11, 13, 10, 1); // (DIN, CLK, LOAD, number of Max7219 chips) // Variable to hold current scores int sSDisplay = 0; // Variables to split whole number into single digits int rightDigit; int middleDigit; int leftDigit; void setup() { lc.shutdown(0, false); // Wake up MAX7219 lc.setIntensity(0, 7); // Set brightness to medium lc.clearDisplay(0); // Clear all displays connected to MAX7219 chip # //Set initial values right to left 1 2 3 //Syntax: Max7219 chip #, Digit, value, DP on or off lc.setDigit(0, 0, 1, false); // lc.setDigit(0, 1, 2, false); lc.setDigit(0, 2, 3, false); delay(3000); } void loop() { sSDisplay++; //convert whole number to single digits rightDigit = sSDisplay % 10; middleDigit = sSDisplay % 100 / 10; leftDigit = sSDisplay % 1000 / 100; // Display extracted digits on the display lc.setDigit(0, 0, rightDigit, false); lc.setDigit(0, 1, middleDigit, false); lc.setDigit(0, 2, leftDigit, false); //Reset when maximum value for 3-digit display has reached //--> Else 'int' maximum value is exceeded quite rapidly and the program will crash if (sSDisplay >= 999) { sSDisplay = 0; delay(5000); } else { delay(100); } }