Hi. I´ve been trying to make a timer. I´m using a 4 digit, 8 segment per digit, display. Handled with a 4051 multiplexer.
I was able to display the numbers individualy. However, when I try to display in every digit at once, it starts flickering and distortioning the numbers.
It´s made with the simple functions present in Arduino UNO r3. I´ve found that it can be fiked with bit angle modulation, but I wasn´t able to found anything within my level.
I´d really apreciate your help, and if any of you could post a link of a BAM tutorial (the simpler the better) it´d be awsome.
Here it is the function for the number 8, which is the one that flickers the most
void Timer::eight(){
digitalWrite(A,HIGH);
digitalWrite(B,LOW);
digitalWrite(C,LOW);
delay(2);
digitalWrite(A,LOW);
digitalWrite(B,HIGH);
digitalWrite(C,LOW);
delay(2);
digitalWrite(A,HIGH);
digitalWrite(B,HIGH);
digitalWrite(C,LOW);
delay(2);
digitalWrite(A,LOW);
digitalWrite(B,LOW);
digitalWrite(C,HIGH);
delay(2);
digitalWrite(A,HIGH);
digitalWrite(B,LOW);
digitalWrite(C,HIGH);
delay(2);
digitalWrite(A,LOW);
digitalWrite(B,HIGH);
digitalWrite(C,HIGH);
delay(2);
digitalWrite(A,HIGH);
digitalWrite(B,HIGH);
digitalWrite(C,HIGH);
delay(2);
}
These are the functions for picking the digit to turn on and picking the number to display.
int Timer::pickDigit(int x){
digitalWrite(powa, LOW); // dig 1
digitalWrite(powb, LOW); // dig 2
digitalWrite( powc, LOW); // dig 3
digitalWrite( powd, LOW); // dig 4
switch(x){
case 1: digitalWrite(powa, HIGH); break;
case 2: digitalWrite(powb, HIGH); break;
case 3: digitalWrite(powc, HIGH); break;
case 4: digitalWrite(powd, HIGH); break;
}
}
int Timer::pickNumber(int x){
switch(x){
case 1: one(); break;
case 2: two(); break;
case 3: three(); break;
case 4: four(); break;
case 5: five(); break;
case 6: six(); break;
case 7: seven(); break;
case 8: eight(); break;
case 9: nine(); break;
default: zero(); break;
}
}
And this is the function for displaying 4 numbers at once
void display(int a,int b,int c,int d){
timer.pickDigit(1);
timer.pickNumber(a);
timer.pickDigit(2);
timer.pickNumber(b);
timer.pickDigit(3);
timer.pickNumber(c);
timer.pickDigit(4);
timer.pickNumber(d);
}
I uploaded the datasheet of the multiplexer for you to check it out if necesary.
Thank you in advance.
397652_DS.pdf (348 KB)