// #define LATCH_PIN 9
// #define CLOCK_PIN 8
// #define DATA_PIN 5
// #define stepperMotor 13
// #define numOfRegisterPins 16
// bool registers[numOfRegisterPins];
/*
Arduino Uno Pin | Device | Device Pin |
=====================================================
2 | 7-Segment | 14 (Dig 1) |
3 | 7-Segment | 11 (Dig 2) |
4 | 7-Segment | 10 (Dig 3) |
5 | 7-Segment | 6 (Dig 4) |
6 | 7-Segment | 13 (A) |
7 | 7-Segment | 9 (B) |
8 | 7-Segment | 4 (C) |
9 | 7-Segment | 2 (D) |
10 | 7-Segment | 1 (E) |
11 | 7-Segment | 12 (F) |
12 | 7-Segment | 5 (G) |
13 | 7-Segment | 8 (Colon) |
*/
// The segment mapping is as follows:
// 7-segment display segment mapping
/*
/-----A-----\
| |
| F | B
| |
------G-------
| |
| E | C /--\
| | |DP|
\------D-----/ \--/
*/
#define DATA_PIN 7
#define LATCH_PIN 8
#define CLOCK_PIN 9
byte digitPins[16] = {
B0000001, //0
B11001111, //1
B0010010, //2
B0000110, //3
B01001100, //4
B0100100, //5
B00100000, //6
B0001111, //7
B00000000, //8
B0000100, //9
B00001000, //A
B01100000, //B
B11110010, //c
B11000010, //d
B10110000, //E
B00111000, //F
};
void setup() {
pinMode(LATCH_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(DATA_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
for (int i=0; i<16; i++) {
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, digitPins[i]);
digitalWrite(LATCH_PIN, HIGH);
Serial.print("Sent: ");
Serial.print(digitPins[i], BIN);
Serial.println(" Decimal: " + String(i));
delay(2000);
}
Serial.println("starting over again!\n");
delay(1000);
}