LED Interfacing With PIC Microcontroller Aim
LED Interfacing With PIC Microcontroller Aim
LED Interfacing With PIC Microcontroller Aim
Aim:
Software Required:
MPLAB Assembler
Procedure:
#include<htc.h>
#include<stdio.h>
__CONFIG(0x3f32);
void main()
TRISC = 0x00;
PORTC = 0x06;
while(1)
RC1 = 0;
RC2 = 1;
_delay(250);
RC1 = 1;
RC2 = 0;
_delay(250);
}
Output:
Result:
Thus, the embedded program for LED interfacing with PIC microcontroller
is executed and the result is verified.
2. LCD interfacing with PIC Microcontroller
Aim:
Software Required:
MPLAB Assembler
Procedure:
#include<htc.h>
#include<stdio.h>
__CONFIG(0x3f32);
void lcd_init();
int main()
TRISD=0x00;
TRISE=0x00;
lcd_init();
lcd_cmd(0x80);
lcd_write(var1);
lcd_cmd(0x89);
lcd_write(var2);
lcd_cmd(0xC0);
lcd_write(var3);
lcd_cmd(0xC7);
lcd_write(var4);
void lcd_init()
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x0e);
PORTD=b;
PORTE=0x01;
_delay(125000);
PORTE=0x00;
PORTD=a;
PORTE=0x05;
_delay(125000);
PORTE=0x04;
}
while(*ch != '\0')
lcd_data1(*ch);
ch++;
}
Output:
Result:
Thus, the embedded program for LCD interfacing with PIC microcontroller
is executed and the result is verified.
3. Switches & Output Devices interfacing with PIC Microcontroller
Aim:
Software Required:
MPLAB Assembler
Procedure:
#include<htc.h>
#include<stdio.h>
__CONFIG(0x3f32);
void main()
TRISB = 0x07;
TRISC = 0x00;
PORTC = 0x06;
while(1)
RC0 = !RB0;
RC1 = RB1;
RC2 = RB2;
_delay(250);
}
Output:
Result:
Thus, the embedded program for switches and output devices interfacing
with PIC microcontroller is executed and the result is verified.
4. Analog input devices & LCD interfacing with PIC Microcontroller
through serial communication
Aim:
To interface analog input devices & LCD with PIC microcontroller through
serial communication.
Software Required:
MPLAB Assembler
Procedure:
#include<htc.h>
#include<stdio.h>
__CONFIG(0x3f32);
void lcd_init();
int main()
TRISB=0X01;
TRISC=0X80;
TXSTA=0X26;
TRISD=0x00;
TRISE=0x00;
TRISA=0XFF;
RCSTA=0X90;
SPBRG=0X40;
ADCON0=0X81;
ADCON1=0x82;
ADRESH=0X00;
PORTB=0X00;
lcd_init();
lcd_cmd(0x80);
lcd_write(var1);
lcd_cmd(0x89);
lcd_write(var2);
lcd_cmd(0xC0);
lcd_write(var3);
lcd_cmd(0xC7);
lcd_write(var4);
while(1)
CHS0=0;
CHS1=0;
CHS2=0;
serial_txr('X');
_delay(500);
lcd_cmd(0x82);
ADGO=1;
while(ADGO==1);
RP0=1;
ADC=ADRESL;
temp1=ADC;
adc_conv(ADC);
RP0=0;
CHS0=1;
CHS1=0;
CHS2=0;
serial_txr('Y');
_delay(500);
lcd_cmd(0xC2);
ADGO=1;
while(ADGO==1);
RP0=1;
ADC=ADRESL;
ldr=ADC;
adc_conv(ADC);
RP0=0;
CHS0=0;
CHS1=1;
CHS2=0;
serial_txr('Z');
_delay(500);
lcd_cmd(0x8b);
ADGO=1;
while(ADGO==1);
RP0=1;
ADC=ADRESL;
ldr=ADC;
adc_conv(ADC);
RP0=0;
}
CHS0=1;
CHS1=1;
CHS2=0;
serial_txr('A');
_delay(500);
lcd_cmd(0xCC);
ADGO=1;
while(ADGO==1);
RP0=1;
ADC=ADRESL;
ldr=ADC;
adc_conv(ADC);
RP0=0;
void lcd_init()
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x0e);
PORTD=b;
PORTE=0x01;
delay();
PORTE=0x00;
PORTD=a;
PORTE=0x05;
delay();
PORTE=0x04;
int temp,hun,ten,one;
temp=c;
hun=(temp/100);
lcd_data1(hun+0X30);
serial_txr(hun+0x30);
_delay(1950);
ten=((temp/10)%10);
lcd_data1(ten+0X30);
serial_txr(ten+0x30);
_delay(1950);
one=(temp%10);
lcd_data1(one+0X30);
serial_txr(one+0x30);
_delay(1950);
delay()
_delay(125000);
_delay(125000);
_delay(25000);
//_delay(25000);
_delay(25000);
TXREG=a;
while(TXIF==0);
}
while(*ch != '\0')
lcd_data1(*ch);
ch++;
}
Output:
Result:
Thus, the embedded program for analog input devices and LCD interfacing
with PIC microcontroller is executed and the result is verified.