Arrch:
crsunu:
*bumpStill waiting on that updated code...
hi Arrch
this is the new code, it works now, but i don't know how good it is
const byte ledCharSet[10] =
{
B00100001, //0 E-F-DP-C-D-B-A-G
B11101011, //1
B01110000, //2
B11100000, //3
B10101010, //4
B10100100, //5
B00100110, //6
B11101001, //7
B00100000, //8
B10101000 //9
};
const int latchPin = 8;
const int clockPin = 10;
const int dataPin = 9;
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
digitalWrite(latchPin, 0);
}
void loop() {
for (int i = 0; i < 100 ; i++) {
DisplayNumber(i);
//delay(100);
}
}
void DisplayNumber(int num) {
int tens;
int ones;
if (num > 100 || num < 0) {
num = 0;
}
ones = num % 10;
if (num < 10) {
tens = 0;
}
else {
tens = num/10;
}
if(num>10){
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, MSBFIRST, B00000001);
shiftOut(dataPin, clockPin, MSBFIRST, ledCharSet[tens]);
digitalWrite(latchPin, 1);
delay(5);
}
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, MSBFIRST, B00000010);
shiftOut(dataPin, clockPin, MSBFIRST, ledCharSet[ones]);
digitalWrite(latchPin, 1);
delay(5);
Serial.print(num);
Serial.print("\t");
Serial.print(tens);
Serial.print("\n");
}