MCU How to display hexadecimal numbers with 1602 LCD

Updated on technology 2024-04-05
19 answers
  1. Anonymous users2024-02-07

    Well, that's about what it looks like.

    There may be spelling mistakes, check for yourself.

    unsigned char hex_table[16] =0', '1', '2', '3', '4', '5', '6', '7',8', '9', 'a', 'b', 'c', 'd', 'e', 'f'

    void display_num(unsigned int num)unsigned int a, b, c, d;

    a = (num/256)/16;Take the 4 bits higher of the high byte.

    b = (num/256)%16;Take the lower 4 bits of the high byte.

    c = (num%256)/16;Take the upper 4 bits of the low byte.

    d = (num%256)%16;Take the lower 4 bits of the low byte.

    write_com(0x80);The initial address displayed.

    write_data('n');

    write_data('u');

    write_data('m');

    write_data('=');

    write_data('0');

    write_data('x');

    write_data(hex_table[a]);

    write_data(hex_table[b]);

    write_data(hex_table[c]);

    write_data(hex_table[d]);

  2. Anonymous users2024-02-06

    void write_hexnum(unsigned char n)if(n>=10) write_data('a'+n); else write_data('0'+n);

    void display_num(unsigned char num)

    write_com(0x80);The initial address displayed.

    write_hexnum(num>>4);High.

    write_hexnum(num&0xf);Low.

  3. Anonymous users2024-02-05

    a=num/16;High.

    b=num%16;Low.

    Add a few more lines of conversion.

    if(a>9)a=a+0x27;

    if(b>9)b=b+0x27;

    And then it's write, the same as what you wrote.

  4. Anonymous users2024-02-04

    Let me give you an example.

    unsigned

    charsd,kk;

    unsigned

    intha=0;

    sd=0x11;

    You're talking about hexadecimal, right?

    kk=16*(sd>>4);

    ha=kk;

    kk=(sd&0x0f);

    ha+=kk;What is stored in the HA is the decimal system of SD.

    To put it simply, ha=(16*(sd>>4))+sd&0x0f);

    Walker === electronic microcontroller.

  5. Anonymous users2024-02-03

    The LCD will only display the value you send in, if it shows hexadecimal, it should be converted to hexadecimal before sending it to display, right? Follow along!

  6. Anonymous users2024-02-02

    The 1602 LCD screen can be moved horizontally.

  7. Anonymous users2024-02-01

    It is not displayed, and only the content of the specified address will be displayed in the corresponding location.

  8. Anonymous users2024-01-31

    51 microcontrollers are for all.

    A general term for microcontrollers compatible with the Intel 8031 command system. The ancestor of this series of single-chip microcomputer is the version of Intel's 8031 single-chip microcomputer, and later with the development of flash ROM technology, 8031 single-chip microcomputer has made great progress, becoming one of the most widely used 8-bit single-chip microcomputers, its representative model is ATMEL AT89 series, which is widely used in industrial measurement and control systems. Many companies have launched compatible models of the 51 series, which will have a large market for a long time to come.

    51 single-chip microcomputer is a basic entry single-chip microcomputer, or the most widely used one. It should be noted that the 52 series microcontrollers generally do not have self-programming capabilities.

    Write a function to extract each bit of integer data, and then you can display each bit of data.

    void display tem(x,y,int getdata) getdata is the data you collected

  9. Anonymous users2024-01-30

    It's simple. Convert the integer number into numbers, such as 23 degrees, convert it to 2 and 3, and then send it to 1602 to display. Don't forget to use the ascii code of numbers, the ASCII code of 0 is 48 (decimal) or 0x30.

    If you still don't understand, you can hi me.

  10. Anonymous users2024-01-29

    Just write a function to break out the integer data bit by bit

    void display tem(x,y,int getdata) getdata is the data you collected

  11. Anonymous users2024-01-28

    Does it mean that the temperature display value will change constantly?

    The temperature is collected once and sent to the display once, so that the displayed data can be changed.

  12. Anonymous users2024-01-27

    dynamic, what kind of dynamics are the requirements??? Can you elaborate on that.

  13. Anonymous users2024-01-26

    temp = p1;Read in.

    temp_h = temp /16;Separate out the upper four digits, which is a 1-digit hexadecimal number.

    temp_l = temp %16;Separate out the lower four digits, which are 1-digit hexadecimal numbers.

    temp_asc = ascii[temp_h];Convert to ASCII code and send it for display.

    temp_asc = ascii[temp_l];Convert to ASCII code and send it for display.

  14. Anonymous users2024-01-25

    I don't understand, isn't the base 2 and base 16 read in the same thing?

    You should be asking how to convert 16 decimal numbers to characters, right?

    Make your own function to turn it, change your thinking:

    For example 0x1a transform:

    Take the lower 4 bits 0x3b&0xf0 to get 0x0b conversion idea 0x0b +'a' - 10) = 'b'

    Take 4 bits higher 0x3b >> 4 bits right to get 0x03 conversion idea 0x03 +'0' = '3'

  15. Anonymous users2024-01-24

    Let's figure out what the question is first, and then we can understand it. What do you mean by this question, are you sure it is Chinese?

  16. Anonymous users2024-01-23

    You can write a string display function first, and then convert the floating-point number to a string, and you can do it;

    extern char *dtostre(double __val, char *_s, unsigned char __prec,unsigned char __flags);

    Floating-point notation:

    extern char *dtostrf(double __val, char __width, char __prec, char *_s);

    LCD1602, industrial character type liquid crystal, can display 16x02 i.e. 32 characters at the same time.

  17. Anonymous users2024-01-22

    Decimals cannot be displayed directly, and single-chip microcomputer operations are integers. You need to use an algorithm to represent the decimal of the result of a formula, and then add the decimal point to the integer part and the decimal part.

  18. Anonymous users2024-01-21

    Insert the decimal point programmatically.

  19. Anonymous users2024-01-20

    Either there is a problem with the program, or the data you wrote in the program is too fast for the LCD to be busy.

Related questions
10 answers2024-04-05

Ignoring the influence of temperature and other factors, the method of measuring voltage by series resistance can be directly adopted. >>>More

4 answers2024-04-05

You use a P1 port to control the dynamic scanning of 8 digital tubes, and the dynamic scanning display of digital tubes needs to be blanked. >>>More

4 answers2024-04-05

Learning single-chip microcomputer is very promising and promising. >>>More

2 answers2024-04-05

Summary. Please tell me about the specific question, dear. >>>More

8 answers2024-04-05

void key0()

if(p1_0!=1) *If the key 0 is pressed. >>>More