Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup()
- {
- /* setup pins etc*/
- while(!(PINB & 0b100));//wait for input 1
- TCCR1A = 0;// set entire TCCR1A register to 0
- TIMSK1 = _BV(TOIE1); //enalbe interrupt
- TCCR1B = 1;// start timer 1
- while(!(PINA & 0b1000000));//wait for input 2
- cli();
- TCCR1B = 0; //stop timer;
- temp_timer = TCNT1; //store passed ticks
- TCCR1A = 0; // disable timer1
- TCCR1B = 0;
- time = (0xFFFFul * (unsigned long)overflows) + (unsigned long)temp_timer; //calculate time
- /*display speed*/
- }
- ISR(TIMER1_OVF_vect)
- {
- overflows++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement