1.LED
2.LCD
LED
code :
void main(){
TRISB = 0; // set pin as output
do {
LATB = 0x00; // Turn OFF LEDs on PORTB
Delay_ms(1000); // delay of 1 sec
LATB = 0xFF; // Turn ON LEDs on PORTB
Delay_ms(1000); // delay of 1 sec
} while(1); // infinite loop
}
circuit
LCD
You can download the code and proteus file below
Code :
// LCD connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// LCD connections
void main() {
ADCON1 |= 0x0F;
CMCON |= 7;
Lcd_Init(); // Inicializa LCD
Lcd_Cmd(_Lcd_CLEAR); // Limpiar display
Lcd_Cmd(_Lcd_CURSOR_OFF); // Desactivar cursor
while(1)
{
Lcd_Out(1,1,"Hello World");
Lcd_Out(2,1,"its ecworks");
}
}
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// LCD connections
void main() {
ADCON1 |= 0x0F;
CMCON |= 7;
Lcd_Init(); // Inicializa LCD
Lcd_Cmd(_Lcd_CLEAR); // Limpiar display
Lcd_Cmd(_Lcd_CURSOR_OFF); // Desactivar cursor
while(1)
{
Lcd_Out(1,1,"Hello World");
Lcd_Out(2,1,"its ecworks");
}
}
circuit