[Solved] Strobing to Light Four 7-Segment Displays; Not Working Properly
so got little 7-segment bubble display 4 digits sparkfun. got 1 of shift registers (74hc595n). i've had success in past getting these work together. have issue.
i'm trying timer using these. coded number, 300, scetch 4 different values: a=0,b=3,c=0,d=0. after squashing bugs, works.... except when reaches 0267, digits except last go blank (it remains on 8) , stops counting. thinkng arduino (uno) going bad after abuse sent through, uploaded code new(er) uno. still acts same. seems though stops executing code after time.
the 2 conditions in loop are
and
neither of 2 designed stop execution of code.
i'm trying timer using these. coded number, 300, scetch 4 different values: a=0,b=3,c=0,d=0. after squashing bugs, works.... except when reaches 0267, digits except last go blank (it remains on 8) , stops counting. thinkng arduino (uno) going bad after abuse sent through, uploaded code new(er) uno. still acts same. seems though stops executing code after time.
the 2 conditions in loop are
code: [select]
now=millis();
while(millis() - < 1000){
and
code: [select]
seconds = (a*1000)+(b*100)+(c*10)+d;
if(seconds>0){
neither of 2 designed stop execution of code.
code: [select]
// define numbers
const int numbers[] = {0b11111100,0b01100000,0b11011010,0b11110010,0b01100110,0b10110110,0b00111110,0b11100000,0b11111110,0b11100110}; // 0-9
// set enable pin
const int en = 10; // set low when sending data
// these digits on display
const int a1 = 2;
const int a2 = 3;
const int a3 = 4;
const int a4 = 5;
//data,clock
const int sda = 7;
const int sck = 8;
//set digits
int a;
int b;
int c;
int d;
//we'll need these timing
int now;
int seconds;
void setup(){
pinmode(en,output);
pinmode(a1,output);
pinmode(a2,output);
pinmode(a3,output);
pinmode(a4,output);
pinmode(sda,output);
pinmode(sck,output);
digitalwrite(en,1);
delay(10);
digitalwrite(en,0);
shiftout(sda,sck,lsbfirst,0);
digitalwrite(en,1);
a=0;
b=3;
c=0;
d=0;
}
void loop(){
now=millis();
while(millis() - < 1000){
digitalwrite(en,0);
shiftout(sda,sck,lsbfirst,numbers[a]);
digitalwrite(a1,1);digitalwrite(a2,1);digitalwrite(a3,1);digitalwrite(a4,1);
digitalwrite(en,1);
digitalwrite(a1,0);digitalwrite(a2,1);digitalwrite(a3,1);digitalwrite(a4,1);
delay(1);
digitalwrite(en,0);
shiftout(sda,sck,lsbfirst,numbers[b]);
digitalwrite(a1,1);digitalwrite(a2,1);digitalwrite(a3,1);digitalwrite(a4,1);
digitalwrite(en,1);
digitalwrite(a1,1);digitalwrite(a2,0);digitalwrite(a3,1);digitalwrite(a4,1);
delay(1);
digitalwrite(en,0);
shiftout(sda,sck,lsbfirst,numbers[c]);
digitalwrite(a1,1);digitalwrite(a2,1);digitalwrite(a3,1);digitalwrite(a4,1);
digitalwrite(en,1);
digitalwrite(a1,1);digitalwrite(a2,1);digitalwrite(a3,0);digitalwrite(a4,1);
delay(1);
digitalwrite(en,0);
shiftout(sda,sck,lsbfirst,numbers[d]);
digitalwrite(a1,1);digitalwrite(a2,1);digitalwrite(a3,1);digitalwrite(a4,1);
digitalwrite(en,1);
digitalwrite(a1,1);digitalwrite(a2,1);digitalwrite(a3,1);digitalwrite(a4,0);
delay(1);
}
// subtract second
seconds = (a*1000)+(b*100)+(c*10)+d;
if(seconds>0){
seconds--;
a=seconds/1000;
b=seconds/100 - (a*10);
c=seconds/10 - (a*100) - (b*10);
d=seconds - (a*1000) - (b*100) - (c*10);
}
}
Arduino Forum > Using Arduino > LEDs and Multiplexing > [Solved] Strobing to Light Four 7-Segment Displays; Not Working Properly
arduino
Comments
Post a Comment