As stated before, i didn't want to use long delays to separate between photos. What I wanted was for the MC to wake up, check if it timed out and if so take a pic. To do so I altered the ISR code relative to the watchdog timer, to this:
ISR(WDT_vect) { seconds++; if (state==RUN) { timeout--; if(timeout==0) { shoot(); variable_blink(50,10,1); timeout=duration; } } }
I also made some changes to the ISR function with the Interrupt vector to this:
ISR(PCINT0_vect) { unset_interrupt();// halts interrups to avoid interference _delay_ms(250); //helps to debouce switch(state) { case START_P: start_second = get_seconds(); // gets initial second blink(1); state=STOP_P; break; case STOP_P: stop_second = get_seconds();// gets final second duration = stop_second - start_second;// calculates duration in seconds stored_duration = duration; // stores the base duration timeout=duration; blink(1); state=RUN; break; default: break; } set_interrupt();
With these changes and using the led to debug everything looked OK. But as we all will see it was still too soon to celebrate...
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.