Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- #include <stdbool.h>
- #include <string.h>
- bool debButton(char *pin[], int x) // <---- CZY TU JEST DOBRZE PRZEKAZANE
- {
- _delay_ms(20);
- if(bit_is_clear(*pin, x)) // <---- TUTAJ DZIAŁA
- {
- PORTB &= ~(1 << PINB3);
- while ((bit_is_clear(*pin, x))) // <---- TU JUZ NIE DZIAŁA
- {
- }
- PORTB &= ~(1 << PINB3);
- return true;
- }
- else
- {
- PORTB &= ~(1 << PINB3);
- return false;
- }
- }
- void main(void)
- {
- DDRB |= 1 << PINB0;
- DDRB &= ~(1 << PINB1);
- DDRB |= 1 << PINB2;
- DDRB |= 1 << PINB3;
- PORTB |= 1 << PINB1;
- PORTB |= 1 << PINB3;
- //bool redLed =0;
- while(1)
- {
- if(bit_is_clear(PINB,1))
- {
- PORTB |= 1 << PINB0;
- if(debButton("PINB",1)) // <---- TU JEST WYWOLANA TA CALA FUNKCJA
- {
- PORTB ^= 1 << PINB2;
- }
- else
- {
- }
- }
- else
- {
- PORTB &= ~(1 << PINB0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement