Answer : please up vote or comment for any query i will update the same . Thanks.
Note : ---- please disable JTAG using FUSE bit while compiling program or manually setting fuse bit otherwise program will not work on PORTC .
Program Plan :
1. set Switch as INPUT and turn on pull up resistor
2. set OUTPUT all three LED PINS
3. check for switch PIN went LOW to TURN ON LED
4. increment count variable when switch pressed and write count value to PORTC
Program :
#include <avr/io.h>
#include <util/delay.h>
void PORTInit(void);
int main(void)
{
int count=0;
PORTInit();
while(1) //infinite loop
{
if(PINC & (1<<PC3) == 0) //If switch is pressed detect
LOW
{
count++;//increment count
PORTC=count;//write switch counter to port c
PORTC|=(1<<PC3); //above line may reset pull up so re
initialize
if(count==8) //more than 8 will not affect PORTC LED PINS so again
zero
{
count=0;
}
_delay_ms(300); //300 milli second delay for debounce
}
}
}
void PORTInit(void)
{
DDRC|=(1<<PC0)|(1<<PC1)|(1<<PC2); //set LED0
,LED1 and LED2 as output
DDRC&=~(1<<PC3); //set switch as input PORTC pin3
PORTC|=(1<<PC3); //pull up enable for switch
}
can you please solve in c and clear 1 - General purpose eneral purpose 1/0 [30...