Program for Sensor test

microcontroller – atmega 8535

PINA -SENSOR MODULE CONNECTED

PORT C-BUZZER MODULE

PROGRAM:

#include<avr/io.h>        //This is the header for AVR Microcontroller.
#include”delay.h”       //This is the working header file for delay.

void main()
{
    PORTC=0X00;            // PortC initiallization as all bits low.
    DDRC=0X08;            // PortC data direction declaration as out put.
    
    PORTA=0XFF;            // PortA initiallization as all bits high.
    DDRA=0X00;            // PortA data direction declaration as input.
    
    while(1)            //This is for the the infinity loop.
    {    
        if((PINA&0x01)==0x00)    // Sensor at PA0 is sensing Obstacle
         {
           PORTC=0x08;            // Buzzer ON
         }
        else
         {
          PORTC=0X00;            // Buzzer OFF
         }
    }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s