Managing LCD with pic

MrChips

Joined Oct 2, 2009
30,824
You can also do this:

Rich (BB code):
void LCD_Select(char LCD)
{
   if (LCD)
     {
        LCD_SELECT = 1;
     }
   else
     {
        LCD_SELECT = 0;
     }

}
Now you can call

LCD_Select(LCD0);

or

LCD_Select(LCD1);

if
#define LCD0 0
#define LCD1 1

or you may prefer:

LCD_Select(0);
LCD_Select(1);
 

Thread Starter

JridiHamza

Joined Jul 22, 2014
18
Thnaks to all of you guys it works very well now :)

Rich (BB code):
#include <main.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOPUT, NOBROWNOUT,NOLVP
#define LCD_ENABLE_PIN PIN_A2
#define LCD_RS_PIN PIN_A0
#define LCD_RW_PIN PIN_A1
#define LCD_DATA4 PIN_c4
#define LCD_DATA5 PIN_C5
#define LCD_DATA6 PIN_C6
#define LCD_DATA7 PIN_C7
#include <lcd.c>

#define LCD_SELECT PIN_B7  //name the selector pin 'SELECT'

void LCD_Select1(void)
{
   // output logic LOW to LCD_SELECT
 //LCD_SELECT = 0;
 output_low(pin_B7);
}

void LCD_Select2(void)
{
   // output logic HIGH to LCD_SELECT
 //LCD_SELECT = 1;
 output_high(pin_B7);
}

void init_Displays(void)
{
 LCD_Select1();
 lcd_init();
 lcd_putc("1 Initialized");

 LCD_Select2();
 lcd_init();
 lcd_putc("2 Initialized");
}

void Display(void)
{
 LCD_Select1();
 lcd_init();
 lcd_putc("Message 1");

 LCD_Select2();
 lcd_init();
 lcd_putc("Message 2");
}
void main()
{
init_displays();
delay_ms(3000);
   while(TRUE)

   { 
     display(); 
   }

}
 

Attachments

JohnInTX

Joined Jun 26, 2012
4,787
And nothing succeeds like success. Well done!

What's the push button for on the ENABLE line?

EDIT: Since you are early in the development, consider trying some of the other methods described in the thread. Anytime you can eliminate some hardware c.f. RB's two resistors, its a good thing. You always have the working one to come back to.
 
Last edited:

Thread Starter

JridiHamza

Joined Jul 22, 2014
18
And nothing succeeds like success. Well done!

What's the push button for on the ENABLE line?

EDIT: Since you are early in the development, consider trying some of the other methods described in the thread. Anytime you can eliminate some hardware c.f. RB's two resistors, its a good thing. You always have the working one to come back to.
thnx bro :)
fot the push button I used to use the pull down resistor on that way for leds e.g but I understand now that it's a mistake :)
 

MrChips

Joined Oct 2, 2009
30,824
It's all a collaborative group effort. And the best part is the advice is free. That's what I like about AAC.

Pat yourself on the back.
 
Top