const int a = 3;
const int b = 4;
const int c = 5;
const int d = 6;
const int e = 7;
const int f = 8;
const int g = 9;
const int h = 10;
// ? is the ternary or the conditional operator instead of the if else
// if the given condition is true the left side of the colon is executed and vice versa
void printdata(unsigned char data) {
digitalWrite(a, (data & 0x01) ? HIGH : LOW);
digitalWrite(b, (data & 0x02) ? HIGH : LOW);
digitalWrite(c, (data & 0x04) ? HIGH : LOW);
digitalWrite(d, (data & 0x08) ? HIGH : LOW);
digitalWrite(e, (data & 0x10) ? HIGH : LOW);
digitalWrite(f, (data & 0x20) ? HIGH : LOW);
digitalWrite(g, (data & 0x40) ? HIGH : LOW);
digitalWrite(h, (data & 0x80) ? HIGH : LOW);
}
unsigned char seg[10] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7c, 0x07, 0x7f, 0x6f};
void setup() {
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(h, OUTPUT);
}
void loop() {
for (int i = 0; i < 10; i++) {
printdata(seg[i]);
delay(1000);
}
}