#define ROW1 A0
#define ROW2 A1
#define ROW3 A2
#define ROW4 A3
#define ROW5 A4
#define COL1 2
#define COL2 3
#define COL3 4
#define COL4 5
const byte rows[]{
ROW1,ROW2,ROW3,ROW4,ROW5
};
void setColumns(byte b) {
digitalWrite(COL1, (~b >> 0) & 0x01); // Get the 1st bit: 10000000
digitalWrite(COL2, (~b >> 1) & 0x01); // Get the 2nd bit: 01000000
digitalWrite(COL3, (~b >> 2) & 0x01); // Get the 3rd bit: 00100000
digitalWrite(COL4, (~b >> 3) & 0x01); // Get the 4th bit: 00010000
}
//fonts
byte OFF[] = {B0000,B0000,B0000,B0000,B0000};
byte ALL[] = {B1111,B1111,B1111,B1111,B1111};
byte A[] = {B1111,B1001,B1111,B1001,B1001};
byte S[] = {B1111,B0001,B1111,B1000,B1111};
byte U[] = {B1001,B1001,B1001,B1001,B1111};
byte H[] = {B1001,B1001,B1111,B1001,B1001};
byte D[] = {B1111,B1010,B1010,B1010,B1111};
byte E[] = {B1111,B0001,B0111,B0001,B1111};
byte R[] = {B1111,B1001,B1111,B0101,B1001};
byte J[] = {B1111,B1111,B0110,B0110,B0011};
byte N[] = {B1001,B1011,B1111,B1101,B1001};
byte I[] ={B1111,B0110,B0110,B0110,B1111};
void drawScreen(byte buffer2[]){
for (byte i = 0; i < 5; i++) {
setColumns(buffer2[i]); // Set columns for this specific row
digitalWrite(rows[i], HIGH);
delay(2); // Set this to 50 or 100 if you want to see the multiplexing effect!
digitalWrite(rows[i], LOW);
}
}
float timeCount = 0;
void setup() {
// Serial.begin(9600);
for (byte i = 2; i <= 5; i++)
pinMode(i, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
}
void loop() {
delay(1);
timeCount += 1;
if(timeCount < 80)
{
drawScreen(OFF);
}
else if (timeCount < 160)
{
drawScreen(OFF);
}
else if (timeCount < 240)
{
drawScreen(S);
}
else if (timeCount < 320)
{
drawScreen(OFF);
}
else if (timeCount < 400)
{
drawScreen(U);
}
else if (timeCount < 480)
{
drawScreen(OFF);
}
else if (timeCount < 560)
{
drawScreen(D);
}
else if (timeCount < 640)
{
drawScreen(OFF);
}
else if (timeCount < 720)
{
drawScreen(E);
}
else if (timeCount < 800)
{
drawScreen(OFF);
}
else if (timeCount < 880)
{
drawScreen(E);
}
else if (timeCount < 960)
{
drawScreen(OFF);
}
else if (timeCount < 1040)
{
drawScreen(R);
}
else if (timeCount < 1120)
{
drawScreen(OFF);
}
else if (timeCount < 1200)
{
drawScreen(A);
}
else if (timeCount < 1280)
{
drawScreen(OFF);
}
else if (timeCount < 1360)
{
drawScreen(ALL);
}
else if (timeCount < 1440)
{
drawScreen(OFF);
}
else {
// back to the start
timeCount = 0;
}
}
Comments
Please log in or sign up to comment.