this my result and the unfinished codes
int latchPin = 10;
int clockPin = 9;
int dataPin = 8;
// digits from the right
const byte digit[10] = //seven segment digits in bits
{
B10000001, // 0
B11110011, // 1
B01001001, // 2
B01100001, // 3
B00110011, // 4
B00100101, // 5
B00000101, // 6
B11110001, // 7
B00000001, // 8 fix
B00100001, // 9
};
void setup()
{
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop()
{
// step through each digit then increment
// the counter by one, until nine
for (int j = 0; j < 10; j++) {
Serial.println(j);
updateShiftRegister(0, j);
delay(1000);
}
}
void updateShiftRegister(int col, int num)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00000101);
shiftOut(dataPin, clockPin, MSBFIRST, digit[num]);
digitalWrite(latchPin, HIGH);
}
SevenSegment.ino (888 Bytes)