/******************************************************************************** Includes ********************************************************************************/ #include #include #include /******************************************************************************** Function Prototypes ********************************************************************************/ void delay_1ms(uint16_t ms); /******************************************************************************** Main ********************************************************************************/ int main( void ) { uint8_t value = 0; uint16_t mydelay; mydelay=50; // configure PORTA as output DDRA = 0xFF; // setup PORTB data direction as an input DDRB = 0; // make sure it is high impedance and will not source PORTB = 0; // main loop while(true) { PORTA = ~value++; delay_1ms(mydelay); if(bit_is_clear(PINB,PB0)) { if(mydelay > 50) mydelay-=25; // wait for user to let go of switch, software debounce while(bit_is_clear(PINB,PB0)) _delay_ms(1); } if(bit_is_clear(PINB,PB1)) { if(mydelay < 5000) mydelay+=25; // wait for user to let go of switch, software debounce while(bit_is_clear(PINB,PB1)) _delay_ms(1); } } } // this wrapper function calls _delay_ms with a known value of 1 // if you call _delay_ms(variable) then the floating point library // is going to be included and your output file gets much larger void delay_1ms(uint16_t ms) { uint16_t i; for(i=0;i