You mean that you have connected the resistor and the led still doesn't turn off?
Can you try a different pin of the mcu, you may have damaged the pin.
You can also check with a voltmeter the state of the pin.
if (!CHECKBIT(PIND,7)) // check if bit1 of portC is 1, or use !CHECKBIT(PINC,1) to check if it is 0
{
SETBIT(PORTC,2); // I assume that you want to set one bit only and not all bits of portA
}
else
{
CLEARBIT(PORTC,2);
}}
return 0;
}
You also have to enable the pullup resistor of the input pin (since you don't have any external pullup) so that when the button grounds the input it can be detected.
Code C - [expand]
1
2
3
DDRC=0XFF;
DDRD=0x00;
PORTD=0x80;// enable pullup resistor for bit 7 input of port D (the button pin)
and the defines don't need to be inside the main, they are usually placed in the first lines of the code so that they can be used before the main too when there is a function