-
#include <dos.h>
-
#include <string.h>
-
#include <conio.h>
-
#include <time.h>
-
-
#define PORTADDRESS 0x378 /* Enter Your Port Address Here */
-
-
#define DATA PORTADDRESS+0
-
#define STATUS PORTADDRESS+1
-
#define CONTROL PORTADDRESS+2
-
-
void lcd_init(void);
-
void lcd_write(char char2write);
-
void lcd_putch(char char2write);
-
void lcd_puts(char * str2write);
-
void lcd_goto(int row, int column);
-
void lcd_clear(void);
-
void lcd_home(void);
-
void lcd_cursor(int cursor);
-
void lcd_entry_mode(int mode);
-
-
-
void main(void)
-
{
-
lcd_init();
-
lcd_goto(1,1);
-
lcd_puts("Welcome To");
-
lcd_goto(1,0);
-
lcd_puts("electroSofts.com");
-
-
while(!kbhit() ) //wait until a key is pressed...
-
{}
-
-
}
-
-
void lcd_init()
-
{
-
-
outportb(CONTROL, inportb(CONTROL) & 0xDF);
-
//config data pins as output
-
-
outportb(CONTROL, inportb(CONTROL) | 0x08);
-
//RS is made high: control (register select)
-
-
lcd_write(0x0f);
-
delay(20);
-
lcd_write( 0x01);
-
delay(20);
-
lcd_write( 0x38);
-
delay(20);
-
-
}
-
-
void lcd_write(char char2write)
-
{
-
-
outportb(DATA, char2write);
-
outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
-
delay(2);
-
outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
-
delay(2);
-
-
}
-
-
void lcd_putch(char char2write)
-
{
-
-
outportb(CONTROL, inportb(CONTROL) & 0xF7);
-
//RS=low: data
-
lcd_write(char2write);
-
-
}
-
-
void lcd_puts(char *str2write)
-
{
-
-
outportb(CONTROL, inportb(CONTROL) & 0xF7);
-
//RS=low: data
-
while(*str2write)
-
lcd_write(*(str2write++));
-
-
}
-
-
void lcd_goto(int row, int column)
-
{
-
-
outportb(CONTROL, inportb(CONTROL) | 0x08);
-
if(row==2) column+=0x40;
-
/* Add these if you are using LCD module with 4 columns
-
if(row==2) column+=0x14;
-
if(row==3) column+=0x54;
-
*/
-
lcd_write(0x80 | column);
-
-
}
-
-
void lcd_clear()
-
{
-
-
outportb(CONTROL, inportb(CONTROL) | 0x08);
-
lcd_write(0x01);
-
-
}
-
-
void lcd_home()
-
{
-
-
outportb(CONTROL, inportb(CONTROL) | 0x08);
-
lcd_write(0x02);
-
-
}
-
-
void lcd_entry_mode(int mode)
-
{
-
-
/*
-
if you dont call this function, entry mode sets to 2 by default.
-
mode: 0 - cursor left shift, no text shift
-
1 - no cursor shift, text right shift
-
2 - cursor right shift, no text shift
-
3 - no cursor shift, text left shift
-
*/
-
outportb(CONTROL, inportb(CONTROL) | 0x08);
-
lcd_write(0x04 + (mode%4));
-
-
}
-
-
void lcd_cursor(int cursor)
-
{
-
-
/*
-
set cursor: 0 - no cursor, no blink
-
1 - only blink, no cursor
-
2 - only cursor, no blink
-
3 - both cursor and blink
-
*/
-
-
-
outportb( CONTROL, inportb(CONTROL) | 0x08 );
-
lcd_write( 0x0c + (cursor%4));
-
-
}
-
-
--------------------------------------------------------------------------------
-
1 1607
using Turbo C V3.0 this code compiles and links OK
Have not tried to run it!
what is your problem?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ^CeFoS^ |
last post by:
Hello to everybody,
I've done an application that draws in a frame the trajectory of a
robot. The robot position is readed through the serial port, and
several commands are wrote through the...
|
by: MNQ |
last post by:
Hi All
I want to use my parallel port of my PC to control some external devices. I
am writing a program in ANSI C using the PacificC compiler. What I need to
know is how to access the parallel...
|
by: halukg |
last post by:
I am trying to send a 6 byte char array from the serial port in new C# 2005
Express:
com.Write(new string(new char { (char)34, (char)14, (char)192, (char)51,
(char)0, (char)0 }, 0, 6));
I am...
|
by: kai |
last post by:
Hi,
I was tring to run an example (HelloWorld.aspx) from MSPrss book, I get
this message:
"ASP.NET Development Server faild to start listening port 1034.
Error message:
An attempt was made...
|
by: henrycortezwu |
last post by:
Hi All,
I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth
Serial Port") using VS2005 System.IO.Ports.
When I ran the ff code below here's what happens.
1) VS2005 Compiles w/o...
|
by: vorange |
last post by:
Hello,
I have a problem I have been unable to solve for quite some
time now. I'm using the Serialport class and opening the port and
writing a byte to it. The byte is successfully received by...
|
by: Phoe6 |
last post by:
Hi,
The following piece of code works properly when my proxy password
contains characters etc. But when my proxy password
contained something like '|\/|' , the httplib incorrectly indentified
it...
|
by: mmcgee00 |
last post by:
Hi,
Currently, I am trying to get different service banner by connecting
to different ports using python (code below). The versions I am
working with are python 4.2.1 and fedora core 4. I am...
|
by: blunt |
last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| | |