#include <MD_Parola.h>
#include <LedControl.h>
LedControl lc=LedControl(11,13,10,1); //DIN,CLK,CS,Number of MAX7219 modules
void setup() {
lc.shutdown(0,false); //Wake up MAX7219 (0 for module 1)
lc.setIntensity(0,8); //Set brightness (0 for module 1)
lc.clearDisplay(0); //Clear display (0 for module 1)
}
void loop() {
//Read input from dip switch
int dipSwitchValue = 0;
for(int i = 0; i <= 7; i++) {
dipSwitchValue |= digitalRead(i + 2) << i;
}
//Display value on LED screen
if(dipSwitchValue < 10) {
lc.setDigit(0,0,dipSwitchValue,false); //Display single digit
} else {
switch(dipSwitchValue) {
case 10:
lc.setChar(0,0,'A',false); //Display A
break;
case 11:
lc.setChar(0,0,'B',false); //Display B
break;
case 12:
lc.setChar(0,0,'C',false); //Display C
break;
case 13:
lc.setChar(0,0,'D',false); //Display D
break;
case 14:
lc.setChar(0,0,'E',false); //Display E
break;
case 15:
lc.setChar(0,0,'F',false); //Display F
break;
default:
lc.setDigit(0,0,0,false); //Display 0 if value is invalid
break;
}
}
}