Skip to main content

Posts

Showing posts from June, 2017

Interfacing of Push Button With ATmega16

In this tutorial, we will learn how to interface a switch(push button) with ATMEGA16 using AVR studio. In the previous video, we learnt how to interface LEDs with ATMEGA16 using AVR studio. The push-button is a component that connects two points in a circuit when you press it. The example turns on an LED when you press the button. Here we have connected two push button to PORT C in  PC0 & PC1. And for LEDs connection please refer my previous blog. Components Required:- AVR Controller(Atmega16) LEDs Push Button Connecting Wires USBASP Programmer Dump the following code after connection  and select chip ATMEGA 16. #include<avr/io.h> #include<util/delay.h> void main()  {    DDRB=0b11111111;    int S1;    int S2;      while(1)    {     S1=PINC&0b00000001;     S2=PINC&0b00000010;     if(S1==0b00000001)     {      PORTB=0b00000001;      _delay_ms(100);      }      if(S2==0b00000010)     {      PORTB=0b00000010;      _delay_ms(100);