#include "ssd.h"
// Added another ssd
// changed the macros in ssd.h for more easier pin assignmnet
// passing message from "msg" array
static unsigned char ssd[MAX_SSD_CNT];
unsigned char msg[] = {BLANK,BLANK,BLANK, BLANK, FIVE, ZERO, FIVE ,BLANK,BLANK};
int size = (sizeof(msg)/sizeof(msg[0]));
static unsigned char sample[4];
unsigned char sw(int val){
unsigned char VAL;
switch(val){
case 0:
VAL = ZERO;
break;
case 1:
VAL = ONE;
break;
case 2:
VAL = TWO;
break;
case 3:
VAL = THREE;
break;
case 4:
VAL = FOUR;
break;
case 5:
VAL = FIVE;
break;
case 6:
VAL = SIX;
break;
case 7:
VAL = SEVEN;
break;
case 8:
VAL = EIGHT;
break;
case 9:
VAL = NINE;
break;
default:
VAL = BLANK;
break;
}
return VAL;
}
void setup() {
Serial.begin(9600);
init_ssd();
}
void loop() {
static int wait = 0;
static int i = 0;
Serial.println("Enter 4 digit message !");
if (Serial.available() >= 4) {
for (int j = 0; j < 4; j++) {
char digit = Serial.read();
int val = digit - '0';
if (val >= 0 && val <= 9) { // Adjust the range based on your needs
sample[j] = sw(val);
} else {
// Handle invalid input if needed
sample[j] = BLANK;
}
}
}
ssd[0] = sample[0];// uncomment this for uart
ssd[1] = sample[1]; // comment below msg[i] code
ssd[2] = sample[2];
ssd[3] = sample[3];
// ssd[0] = msg[i]; // comment the serial.begin
// ssd[1] = msg[i+1]; //and use this to see normal "sos" message
// ssd[2] = msg[i+2];
// ssd[3] = msg[i+3];
display(ssd);
if (!wait--) { // introducing delay
wait = 2000;
i++;
if(i == size -2)
i = 0;
}
}