IR Sensor interfacing with microcontroller (Mikro C)
Welcome To MINA TECHNOLOGY.
In this tutorial we will learn how to interface IR Sensor with Microcontroller. Here I am use PIC16F877A Microcontroller and LM16x2 Lcd display. You can watch the video or read the written tutorial below.
IR SENSOR
The IR sensor consist IR signal transmitter and IR signal reciver. The IR signal transmitter emit infrared light. The infrared light is not visible of human eye.
The IR signal reciver is recived the infrared light. When the obstacles or surfaces come in front the IR sensor then the infrared light is reflection. The IR signal reciver is recived this infrared light reflection.
CIRCUIT DIAGRAM
Mikro C Code:
# define SW PORTD.RD7
// Start Lcd module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End Lcd module connections
char text1[] = "No Object detect";
char text2[] = " Object Detect ";
void main() {
TRISD = 0X80;
PORTD = 0X00;
Lcd_Init(); // Initialize Lcd module
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,3,"DEVELOPED BY");
Lcd_Out(2,1,"MINA TECHNOLOGY");
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"IR Interfacing");
while(1){
if(SW==0){
Lcd_Out(2,1,text2);
}
if(SW==1){
Lcd_Out(2,1,text1);
}
}
}
Click the download button for program file:
In this tutorial we will learn how to interface IR Sensor with Microcontroller. Here I am use PIC16F877A Microcontroller and LM16x2 Lcd display. You can watch the video or read the written tutorial below.
IR SENSOR
The IR sensor consist IR signal transmitter and IR signal reciver. The IR signal transmitter emit infrared light. The infrared light is not visible of human eye.
The IR signal reciver is recived the infrared light. When the obstacles or surfaces come in front the IR sensor then the infrared light is reflection. The IR signal reciver is recived this infrared light reflection.
IR SENSOR |
CIRCUIT DIAGRAM
Mikro C Code:
# define SW PORTD.RD7
// Start Lcd module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End Lcd module connections
char text1[] = "No Object detect";
char text2[] = " Object Detect ";
void main() {
TRISD = 0X80;
PORTD = 0X00;
Lcd_Init(); // Initialize Lcd module
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,3,"DEVELOPED BY");
Lcd_Out(2,1,"MINA TECHNOLOGY");
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"IR Interfacing");
while(1){
if(SW==0){
Lcd_Out(2,1,text2);
}
if(SW==1){
Lcd_Out(2,1,text1);
}
}
}
Click the download button for program file:
download |
No comments