re: 24 sec shot clock



 good day all.

i started code , works count 24 0. however, im confuse should insert button start when button pressed countdown start. pls.

thanks lot

code: [select]


unsigned long currentmillis;
unsigned long previousmillis;
int duration=900;
int counter=25;
int ptens=0;
int pones=0;
 const int datapin=2;
const int clockpin =3;
const int latchpin=4;
static byte digitdisplay[10]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};





void setup()
{
    pinmode(datapin,output);
  pinmode(clockpin,output);
  pinmode(latchpin,output);

  serial.begin(9600);
  }

  void loop()

  {
    currentmillis=millis();
    if(currentmillis-previousmillis>duration)
    {
       previousmillis=currentmillis;
       if(counter!=0)
       {
       counter=counter-1;
       }
       if(counter<25 && counter>19)
       {
       ptens=2;
       pones=counter-20;
       digitalwrite(latchpin,high);
       shiftout(datapin,clockpin,msbfirst,digitdisplay[pones]);
        shiftout(datapin,clockpin,msbfirst,digitdisplay[ptens]);
       digitalwrite(latchpin,low);
    }

 if(counter<20 && counter>9)
       {
       ptens=1;
       pones=counter-10;
       digitalwrite(latchpin,high);
       shiftout(datapin,clockpin,msbfirst,digitdisplay[pones]);
        shiftout(datapin,clockpin,msbfirst,digitdisplay[ptens]);
       digitalwrite(latchpin,low);
    }

     if(counter<10)
       {
       ptens=0;
       pones=counter;
       digitalwrite(latchpin,high);
       shiftout(datapin,clockpin,msbfirst,digitdisplay[pones]);
        shiftout(datapin,clockpin,msbfirst,digitdisplay[ptens]);
       digitalwrite(latchpin,low);
    }
    else

   

   
     
      serial.println(counter);
      }
   

    }




how @ end of setup () ?


Arduino Forum > Using Arduino > Programming Questions > re: 24 sec shot clock


arduino

Comments

Popular posts from this blog

Valutazione Template - Joomla! Forum - community, help and support

SD Datastring Convention

First use of Arduino Uno : avrdude error on Blink uploading