Skip to content

Instantly share code, notes, and snippets.

@easai
Created April 22, 2016 02:43
Show Gist options
  • Save easai/2216d8a6517d6b207639d6c545b05fdd to your computer and use it in GitHub Desktop.
Save easai/2216d8a6517d6b207639d6c545b05fdd to your computer and use it in GitHub Desktop.
int pinCLK = 10;
int pinCS = 9;
int pinDIN = 8;
unsigned char dat[8] = {0b010000001,
0b001011010,
0b000100100,
0b001011010,
0b001011010,
0b000100100,
0b001011010,
0b010000001
};
unsigned char heart[8] = {0b00000000,
0b01100110,
0b11111111,
0b11111111,
0b11111111,
0b01111110,
0b00111100,
0b00011000
};
void WriteByte(unsigned char DATA)
{
unsigned char i;
digitalWrite(pinCS, LOW);
for (i = 8; i >= 1; i--)
{
digitalWrite(pinCLK, LOW);
digitalWrite(pinDIN, DATA & 0x80);
DATA = DATA << 1;
digitalWrite(pinCLK, HIGH);
}
}
void writeChar(unsigned char address, unsigned char dat)
{
digitalWrite(pinCS, LOW);
WriteByte(address);
WriteByte(dat);
digitalWrite(pinCS, HIGH);
}
void initDisplay(void)
{
writeChar(0x09, 0x00);
writeChar(0x0a, 0x03);
writeChar(0x0b, 0x07);
writeChar(0x0c, 0x01);
writeChar(0x0f, 0x00);
}
unsigned char smily[8] = {0b00000000,
0b01000010,
0b11100111,
0b01000010,
0b00000000,
0b01000010,
0b00100100,
0b00011000
};
unsigned char handsup[8] = {0b10000001,
0b01011010,
0b00100100,
0b00011000,
0b00011000,
0b00011000,
0b00011000,
0b00100100
};
unsigned char handshoriz[8] = {0b00000000,
0b00011000,
0b11100111,
0b00011000,
0b00011000,
0b00011000,
0b00011000,
0b00100100
};
unsigned char handsdown[8] = {0b00000000,
0b00011000,
0b00100100,
0b01011010,
0b10011001,
0b00011000,
0b00011000,
0b00100100
};
void setup()
{
pinMode(pinCLK, OUTPUT);
pinMode(pinCS, OUTPUT);
pinMode(pinDIN, OUTPUT);
delay(50);
initDisplay();
}
void loop()
{
for (int j = 0; j < 5; j++)
{
for (int i = 1; i < 9; i++)
writeChar(i, handsup[i - 1]);
delay(100);
for (int i = 1; i < 9; i++)
writeChar(i, handshoriz[i - 1]);
delay(100);
for (int i = 1; i < 9; i++)
writeChar(i, handsdown[i - 1]);
delay(100);
for (int i = 1; i < 9; i++)
writeChar(i, handshoriz[i - 1]);
delay(100);
}
for (int i = 1; i < 9; i++)
writeChar(i, smily[i - 1]);
delay(1000);
for (int i = 1; i < 9; i++)
writeChar(i, heart[i - 1]);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment