Friday, 11 November 2016

interfacing of switch in atmega16/32

#include <avr/io.h>

void main()

{

while(1)

{

DDRA=0XFF;

DDRC=0X00;

{

if(PINC&0X01)

{

PORTA=0b00000001;

}

else

{

PORTA=0X00;

}
}
}
}












In this we are using PORTC=0x00 means as input port and PORTA as output port.

Using if condition for switch if (PINC&0X01) means PC0 is press than this pin is high as input.

In proteus search button for switch and earth is connected for doing earth after pressing otherwise pin is high for all time. We also use here pull-down register that’s 10k ohm in hardware also.

And led is connected on PA0 so PORTA=0b00000001 .
    
 
 
 

1 comment:

  1. "Nice and good article.. it is very useful for me to learn and understand easily.. thanks for sharing your valuable information and time.. please keep updating.php jobs in hyderabad.
    "

    ReplyDelete