#define OP_DECODEMODE 9
#define OP_INTENSITY 10
#define OP_SCANLIMIT 11
#define OP_SHUTDOWN 12
#define OP_DISPLAYTEST 15
int CLK=7;
int LOAD=6;
int DIN=5;
void sendData( byte address, byte data)
{
byte packet[2];
byte bitmask;
byte i;
packet[0]=address;
packet[1]=data;
for(i=0;i<2;i++)
for( bitmask=0x80 ; bitmask!=0 ; bitmask=bitmask>>1 )
{
if(bitmask & packet[i]) digitalWrite(DIN,1);
else digitalWrite(DIN,0);
digitalWrite(CLK, HIGH);
digitalWrite(CLK, LOW);
}
digitalWrite(LOAD,HIGH);
digitalWrite(LOAD,LOW);
}
void setup() {
// put your setup code here, to run once:
pinMode(DIN,OUTPUT);
pinMode(CLK,OUTPUT);
pinMode(LOAD,OUTPUT);
digitalWrite(LOAD,LOW);
sendData(OP_DISPLAYTEST, 0);
sendData(OP_INTENSITY, 0);
sendData(OP_SCANLIMIT, 7);
sendData(OP_DECODEMODE, 0);
sendData(OP_SHUTDOWN, 1);
for(int i=0;i<8;i++) sendData(i+1, 0b00000000);
}
uint8_t broj[7][8]={
{0x7C,0xC6,0xCE,0xDE,0xF6,0xE6,0x7C,0x00},// 0
{0x30,0x70,0x30,0x30,0x30,0x30,0xFC,0x00},// 1
{0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00},// 2
{0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00},// 3
{0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x1E,0x00},// 4
{0xFC,0xC0,0xF8,0x0C,0x0C,0xCC,0x78,0x00},// 5
{0x38,0x60,0xC0,0xF8,0xCC,0xCC,0x78,0x00} // 6
};
void showNumber(int n)
{
for(int i=0;i<8;i++) sendData(i+1,broj[n][i]);
}
void loop() {
// put your main code here, to run repeatedly:
showNumber(3);
}