Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16X2 LCD code for pic18f452 - help pls

Status
Not open for further replies.

Eldadgold

New Member
I am trying to connect a 16X2 LCD to a pic18f452 controller.
i understand all the 2X16 LCD displays have the same attachments, anyway the LCD i'm using is - winstar wh1602a
i need the LCD to show a FLOAT data type called volume .
The conections i made:

1 - GND
2- 5V
3- GND
4- RD2
5- GND
6- RD3
11- RD4
12- RD5
13- RD6
14- RD7


from what i could find on the net i wrote the following code (i need to use C programming lamguge...)

***** initialize ****

#include <p18C452.h>
#include <stdio.h>
#include <iostream>
#include <p18f452.h>
#include <delays.h>
#pragma config WDT = OFF // disable watchdog
#include <stdio.h>
#include <iostream>
#include <xlcd.h>
#include <windows.h>
void DelayFor18TCY( void )
{
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
Nop(); Nop(); Nop(); Nop();
Nop(); Nop();
}
void DelayPORXLCD( void )
{
Delay1KTCYx(15); //Delay of 15ms
return;
}
void DelayXLCD( void )
{
Delay1KTCYx(5); //Delay of 5ms
return;
}

****************************************

here comes the (main)
volume is calculated and now i want to write to the LCD

**** writing to LCD *******

OpenXLCD ( EIGHT_BIT & LINES_5X7 ); // configure external LCD
putrsXLCD ("The Volume Is ");
putsXLCD (Volume);

*****************************************

obviosly it doesn't work.
anyone has a working code for the PIC18f452 ?
all i need is initialization and the writing a number (volume) to the screen
Thanx !
 

Pavius

New Member
1) Pin 3 should usually be connected to either a voltage divider or potentiometer, as this controls the contrast. Looking at the datasheet for your LCD confirms this
2) I've never used the LCD library you are using so i can't really know if you are connecting it properly and defining everything as you should - but i did notice that you are passing EIGHT_BIT in the init whereas you connected only 4 data lines (so you are in fact working 4 bit mode).
3) If you'd like to see reference code for an LCD, see my HD44780 driver. It's coded to use PORTC (so connect DB4-7 to RC0-3 or change the definition to whatever port you are using, but use the lower 4 lines). You'll also need to define IO_HD44780_E and IO_HD44780_RS to use whatever port bit you choose.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top