#include <LedControl.h>
const int DIN = 12;
const int CS = 11;
const int CLK = 10;
//byte smile[8]= {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};
//byte neutral[8]= {0x3C,0x42,0xA5,0x81,0xBD,0x81,0x42,0x3C};
//byte frown[8]= {0x3C,0x42,0xA5,0x81,0x99,0xA5,0x42,0x3C};
//byte m[8]= {0xE7,0xFF,0xFF,0xDB,0xDB,0xDB,0xC3,0xC3};
byte One[8] = {0x00,0x00,0x88,0x84,0xFE,0x80,0x80,0x00,};
byte Two[8] = {0x00,0x00,0x88,0xC4,0xA4,0x94,0x88,0x00,};
byte Three[8] = {0x00,0x00,0x82,0x91,0x91,0xA9,0xEE,0x00,};
byte Four[8] = {0x00,0x00,0x3F,0x20,0x20,0x20,0xFF,0x20,};
byte Five[8] = {0x00,0x00,0x9F,0x91,0x91,0x91,0x61,0x00,};
byte Six[8] = {0x00,0x00,0x78,0x8C,0x8A,0x89,0x71,0x00,};
byte Seven[8] = {0x00,0x81,0x41,0x21,0x11,0x09,0x07,0x01,};
byte Eight[8] = {0x00,0x6E,0x91,0x91,0x91,0x91,0x6E,0x00,};
byte Nine[8] = {0x00,0x06,0x09,0x09,0x09,0xFE,0x00,0x00,};
byte Ten[8] = {0x04,0x02,0x01,0xFF,0x00,0xFF,0x81,0xFF,};
byte Eleven[8] = {0x04,0x02,0xFF,0x00,0x04,0x02,0xFF,0x00,};
byte Twelve[8] = {0x04,0x02,0xFF,0x00,0xE4,0x92,0x8A,0x84,};
byte Thirteen[8] = {0x04,0x02,0xFF,0x00,0x82,0x92,0x92,0xFE,};
byte Fourteen[8] = {0x04,0x02,0xFF,0x00,0x1E,0x10,0x10,0xFE,};
byte Fifteen[8] = {0x04,0x02,0xFF,0x00,0x9E,0x92,0x92,0xE2,};
byte Sixteen[8] = {0x04,0x02,0xFF,0x00,0xFE,0x92,0x92,0xE2,};
byte Error[8] = {0x7F,0x49,0x49,0x00,0x7F,0x0D,0x77,0x00,};
LedControl lc=LedControl(DIN,CLK,CS,0);
void setup(){
lc.shutdown(0,false); //The MAX72XX is in power-saving mode on startup
lc.setIntensity(0,1); // Set the brightness to maximum value
lc.clearDisplay(0); // and clear the display
Serial.begin(9600);
}
void loop(){
int Number = analogRead(A0);
int checknum = Number/64+1;
if(checknum == 1){
printByte(One);
}else if(checknum == 2){
printByte(Two);
}else if(checknum == 3){
printByte(Three);
}else if(checknum == 4){
printByte(Four);
}else if(checknum == 5){
printByte(Five);
}else if(checknum == 6){
printByte(Six);
}else if(checknum == 7){
printByte(Seven);
}else if(checknum == 8){
printByte(Eight);
}else if(checknum == 9){
printByte(Nine);
}else if(checknum == 10){
printByte(Ten);
}else if(checknum == 11){
printByte(Eleven);
}else if(checknum == 12){
printByte(Twelve);
}else if(checknum == 13){
printByte(Thirteen);
}else if(checknum == 14){
printByte(Fourteen);
}else if(checknum == 15){
printByte(Fifteen);
}else if(checknum == 16){
printByte(Sixteen);
}else{
printByte(Error);
}
//lc.clearDisplay(0);
}
void printByte(byte character [])
{
int i = 0;
for(i=0;i<8;i++)
{
lc.setRow(0,i,character[i]);
}
}
Comments