Skip to main content

Posts

Showing posts from June, 2017

Interfacing Of Switch (Push-Button) With ATMEGA16 Using AVR Studio

In this tutorial, we will learn how to interface a switch(push button) with ATMEGA16 using AVR studio.In 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.
Link-  http://sudolearn.blogspot.in/2017/05/getting-started-with-embedded-system.html
Components Required:-
AVR Controller(Atmega16)LEDsPush ButtonConnecting WiresUSBASP 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)
    {
     PO…