Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 1000000UL
- #include <avr/io.h>
- #include <avr/interrupt.h>
- int main(void)
- {
- DDRB&= ~(1<<PINB0);
- PORTB|= (1<<PINB0);
- DDRB|= (1<<PINB6);
- int pressed=0;
- int pressed_conf=0;
- int released_conf=0;
- int UBRR_val=25;
- UBRR0H = (unsigned char) (UBRR_val >> 8);
- UBRR0L = (unsigned char) UBRR_val;
- UCSR0B = (1 << RXEN0) | (1 << TXEN0);
- UCSR0C |= (1 << USBS0) | (3 << UCSZ00);
- while(1)
- {
- if( bit_is_clear(PINB, 0) )
- {
- pressed_conf++;
- released_conf=0;
- if(pressed_conf >100)
- {
- if(pressed==0)
- {
- pressed=1;
- PORTB ^= (1<<PINB6);
- while ( !(UCSR0A &(1 <<UDRE0)) )
- {
- UDR0 = 0b11111111;
- }
- }
- pressed_conf=0;
- }
- }
- else
- {
- released_conf++;
- pressed_conf=0;
- if(released_conf >100)
- {
- pressed=0;
- released_conf=0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement