Home > other >  Using proteus simulation, can export lcd1602 display content? Figure and principle of the code
Using proteus simulation, can export lcd1602 display content? Figure and principle of the code

Time:10-11

The hardware schematic diagram is as follows:

I want to put on the LCD display real-time content stored in the database, rather than directly through the lcd1602 display, is a direct copy and paste is ok?

Stick the lcd1602 code,

 
Include "LCD1602. H"


Sbit lcd_port_rs=lcd_port_rs;
Sbit lcd_port_e=lcd_port_e;


///////////////////////////LCD latency, waiting for the command//////////////////////
# ifdef MCU_STC89
Void lcd_delay (char j)
{
int i=0;
While (j)
for(i=0; i<60; i++);
}
# endif
# ifdef MCU_STC12
Void lcd_delay (char j)
{
int i=0;
While (j)
for(i=0; i<160; i++);
}
# endif
//////////////////////////////////////////////////////////////////////////////




//write command, falling edge written
Void lcd_en ()
{
Lcd_port_e=1;
Lcd_delay (1);
Lcd_port_e=0;
}

///////////////////////////write content: rs_mode 0 as the instruction, 1 for the data//////////////////////
# ifdef LCD_DATA_8_LINE
Void lcd_write (char rs_mode, unsigned char value)
{
Lcd_port_rs=rs_mode;
LCD_PORT_DATA=https://bbs.csdn.net/topics/value;
Lcd_en ();
Lcd_delay (1);
}
# endif
# ifdef LCD_DATA_4_LINE
Void lcd_write (char rs_mode, unsigned char value)
{
Lcd_port_rs=rs_mode;
//first sends high four
LCD_PORT_DATA & amp;=0 x0f;//use the data in four high output, low four constant, high four reset
LCD_PORT_DATA |=value& 0 xf0; 4//low and high value for assignment 4 4
Lcd_en ();
Lcd_delay (1);
//low then sending four
LCD_PORT_DATA & amp;=0 x0f;
LCD_PORT_DATA |=value<4. 4//low and high value for assignment 4 low 4
Lcd_en ();
Lcd_delay (1);
}
# endif
//////////////////////////////////////////////////////////////////////////////


//initialize
Void lcd_init ()
{
Lcd_delay (80);//40 ms, waiting VDD> 4.5 V
# ifdef LCD_DATA_8_LINE
Lcd_write (0, 0 x38);//8 bits of data, 2 rows, according to wait for a period of time
Lcd_delay (20);//10 ms
Lcd_write (0, 0 x38);//8 bits of data, 2 rows, according to wait for a period of time
Lcd_delay (2);//1 ms
# endif
# ifdef LCD_DATA_4_LINE
Lcd_write (0, 0 x33);//line 8, 8 lines
Lcd_delay (20);//10 ms
Lcd_write (0, 0 x32);//line 8, 4 lines
Lcd_delay (20);//10 ms
Lcd_write (0, 0 x28);//4 lines, 2 line shows
Lcd_delay (20);//10 ms
# endif

Lcd_write (0, 0 x01);//clear screen
Lcd_delay (10);
Lcd_write (0, 0 x0c);//display, not flashing cursor, characters
Lcd_write (0, 0 x06);//character did not move, the cursor moves to the right
}

//the specified location written characters, the coordinates x, y coordinates, characters,
Void lcd_write_char (unsigned char x_pos, unsigned char y_pos, char value)
{
//write address
X_pos & amp;=0 x0f;//limits
Y_pos & amp;=0 x01;//limits
If (y_pos) x_pos +=0 x40;//actual location
X_pos +=0 x80;//set the address

Lcd_write (0, x_pos);//write address
Lcd_delay (5);
Lcd_write (1, value);//write data
}


//write is line, the length of the string should be less than 16, is insufficient to cover
Void lcd_write_line (char line, char * STR)
{
char i=0;
for(i=0; i<16. I++)
{
Lcd_write_char (I, line, * (STR + I));
}
}

//write a string, the coordinates x, y coordinates, string, length)
Void lcd_write_str (char x, char y, char * STR, char len)
{
char i=0;
for(i=0; i{
Lcd_write_char (x + I, y, * (STR + I));
}
}



//write Numbers (coordinates x, y coordinates of the data, the integer length, length of decimal)
//the length of the integer, decimal, according to the length=0 for not decimal length less than 5
Void lcd_write_num (char x, char y, double num, char len1, char len2)
{
Long left=0;//decimal point on the left side of the
Long right=0;//decimal point on the right side of the
Signed char I=0;//loop variable
Char ubNegFlag=0;//negative sign, 1 is negative, 0 is positive
If (num<0 {num *=1; UbNegFlag=1; }
Left=(long) num;//decimal point on the left side of the
Right=((long) (num * 100000)) % 100000;//decimal point right, take five significant figures
If (len1 & gt; 0)//if you need to display the integer
{
For (I=x + len1-1; i>=x; I -)//calculate integer area
{
If ((I==x) & amp; Lcd_write_char (ubNegFlag==1)) (x, y, '-');//negative words, according to minus
The else lcd_write_char (I, y, (10) left % + '0');//display
Left/=10;//loop left
}
}
If (len2 & gt; 0)//if you need to display the decimal
{
Lcd_write_char (+ len1 x, y, '. ');//show the decimal point
For (I=x + len1 + 1; i<=x + + len2 len1; I++)//display area
{
Lcd_write_char (I, y, (10)/10000 (right) % + '0');//display
Right *=10;//loop mobile
}
}
}

CodePudding user response:

Don't know what you want to do, the simulation software has the function that you want?
How is the practical application, the single chip microcomputer is have storage available!
Export to the database of 51 single-chip microcomputer can open the database?
If the single chip microcomputer and computer communication, can send data to the computer is the data stored in the database.

CodePudding user response:

reference 1/f, the wise know already should good karma response:
don't know what you want to do, the simulation software has the function that you want?
How is the practical application, the single chip microcomputer is have storage available!
Export to the database of 51 single-chip microcomputer can open the database?
If the single chip microcomputer and computer communication, send data to the computer can save data in databases.

I this is simulation, what do you want to be is an air quality monitoring module, but the sensor is too expensive (3000 a) can't afford it, so just do the simulation, there is no hardware, if there are hardware, like ZigBee can preach data and WiFi, but only the simulation I don't know how to do...
I now this is can walk through, is running on the LCD can display the temperature and humidity (dht11) and five other slide rheostat represents the value of the
I'd like to have these values derived to now, there are local first, then think about the database

CodePudding user response:

Single chip microcomputer and external storage
  • Related