This sensor module gives only two output states that is logic High 1 which is equivalent to 3.3 V and logic low 0 equivalent to 0 V. This sensor uses Infra red beam to detect the motion and only covers a certain space based on the sensor model, i advise you to go through the manufacturer datasheet to know about the range. The PIR sensor detect only bodies (hot materials and living objects) in motions not the static ones. Lets see some of the common applications of PIR sensor for better understanding. This article is going to demonstrate the PIR motion sensor interface with AVR microcontroller.
![ir sensor codevision atmega16 ir sensor codevision atmega16](https://i1.wp.com/www.elecrom.com/wp-content/uploads/2008/02/AVR_Tutorial_Feat_Img_txt.jpg)
![ir sensor codevision atmega16 ir sensor codevision atmega16](https://educdn.ir/2017/08/Ultrasonic-1.png)
These type of sensors have wide range of applications in our daily life and it is essential to learn the interfacing method. PORTA.Passive Infra red sensor also known as PIR sensors is capable of detecting motion or movement within a certain range. PORT=0x2E 3Ĭodevision instructionsPORTA.1=1 // set bit 1, hi. Programming with codevision// External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off GICR|=0x00 MCUCR=0x00 MCUCSR=0x00 // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00 // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off // Analog Comparator Output: Off ACSR=0x80 SFIOR=0x00 Ĭodevision instructionsPORT:Outport a value to parallel ports. Noise Canceler: Off // Input Capture on Falling Edge TCCR1A=0x00 TCCR1B=0x00 TCNT1H=0x00 TCNT1L=0x00 OCR1AH=0x00 OCR1AL=0x00 OCR1BH=0x00 OCR1BL=0x00 // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer 2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected ASSR=0x00 TCCR2=0x00 TCNT2=0x00 OCR2=0x00 Programming with codevision// Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=FFh // OC0 output: Disconnected TCCR0=0x00 TCNT0=0x00 OCR0=0x00 // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer 1 Stopped // Mode: Normal top=FFFFh // OC1A output: Discon. Input/Output Ports initialization // Port A initialization // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T PORTA=0x00 DDRA=0x00 // Port B initialization // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T PORTB=0x00 DDRB=0x00 // Port C initialization // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T PORTC=0x00 DDRC=0x00 // Port D initialization // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T PORTD=0x00 DDRD=0x00 Header for ATMEGA16 deviceDefine variables Programming with codevision#include // Declare your global variables here Programming with CEach program in codevision with wizard have tree partA : Headers : B: initialization part: C: main body :Some basic definition and function you need in your program Some basic settings for futures of device usually compiler generate them. STK200 Programmer cableTo microcontroller To computer parallel Port Minimum system for AT90S2313PORTD PORTB3 1 2 Microcontroller :Device contain a processor and some minimum peripherals such as few memory, timer, UART, PORT, M.GhadiryĪVR microcontrollersAT90s2313:15 IO PINS 1 UART 2 Timer ISP 2KB flash 128 B EEPROM 128 KB SRAM 2 External interrupt 0~12 MHZ operating frequencyĪVR MicrocontrollersATMEGA16:32 IO PINS (4 port) 1 UART 3 Timer ISP 16KB flash 512 B EEPROM 1 KB SRAM 2 External interrupt 0~16 MHZ operating frequency Analog input ports A processor circuit contain ports, RAM, ROM, timer, UART, Processor & MicrocontrollerProcessor :Device that fetch program codes from memory and execute. Motor drivers- BA6219BA6219(output : 2A ,18V) Application :1XDC motor ,left ,right ,break More detecting distanceDetecting distance : about 1 ~ 10 cm How IR sensors works?Sender issue IR signal Receiver sense the reflect of the signal
![ir sensor codevision atmega16 ir sensor codevision atmega16](https://www.elecrom.com/wp-content/uploads/2016/12/s__Infrared-Sensor-Schematic.jpg)
IR sensorsDetect black and white surfacesSender (IR LED ) Receiver ( Photo transistor) Voltage regulator7805 voltage regulator: Input: 7.5 to 12 V Output 5V 800mA Usually we indicate +5v with VCC and other voltages with VS and VDD. VCC ,VDD,VS : Positive pole of DC Power source or battery. What is GND and VCC?GND :The Base for indicating voltage Usually the negative pole of DC power source or battery.
#Ir sensor codevision atmega16 driver
Sample Controller CircuitTo actuators L298 driver At90s2313 microcontroller