I've been trying to finalise some code to drive a multiplexed, 4 digit, seven segment display using the MAX7219 chip. The code below was made from various elements in the Led Contol Playground Article but can't get it to compile correctly.
The Arduino IDE throws the following error:
"too few arguments to function 'void printNumber(int)'
Does anyone know what is wrong with that part of the code?
Thanks in advance.
// Prints an int value (-999..999) on a display with 4 digits
#include "LedControl.h"
/*
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
Using a single MAX7219
*/
LedControl lc=LedControl(12,11,10,1);
unsigned long delaytime=250;
void setup() {
lc.shutdown(0,false); // MAX72XX is in power-saving mode on startup, do a wakeup call
lc.setIntensity(0,8); // Set the brightness to a medium values
lc.clearDisplay(0); // clear the display
}
void printNumber(int v) {
int ones;
int tens;
int hundreds;
boolean negative;
if(v < -999 || v > 999)
return;
if(v<0) {
negative=true;
v=v*-1;
}
ones=v%10;
v=v/10;
tens=v%10;
v=v/10;
hundreds=v;
if(negative) {
lc.setChar(0,3,'-',false); //print character '-' in the leftmost column
}
else {
lc.setChar(0,3,' ',false); //print a blank in the sign column
}
lc.setDigit(0,2,(byte)hundreds,false); // Print the numbers digit by digit
lc.setDigit(0,1,(byte)tens,false);
lc.setDigit(0,0,(byte)ones,false);
}
void scrollDigits() { // Scroll all the hexa-decimal numbers and letters
for(int i=0;i<13;i++) {
lc.setDigit(0,3,i,false);
lc.setDigit(0,2,i+1,false);
lc.setDigit(0,1,i+2,false);
lc.setDigit(0,0,i+3,false);
delay(delaytime);
}
lc.clearDisplay(0);
delay(delaytime);
}
void loop() {
printNumber();
scrollDigits();
}