I am trying to make a button debounce software by the help of an led toggle function that returns a different boolean each time which i got by asking the question before but that never worked :
#include <avr/io.h>
bool ledToggle();
int main(void)
{
DDRB |= (1 << 0);
DDRB &= ~(1 << 0);
while(1)
{
//TODO:: Please write your application code
if (ledToggle() == true)
{
//led on
PORTB |= (1 << 0);
}else{
//led off
PORTB &= ~(1 << 0);
}
}
}
bool ledToggle()
{
static bool state = false;
if(bit_is_clear(PINB, 1)){
state = !state;
}
return state;
}
EDIT
I get no errors or anything when I try to compile it just doesn't work...