FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    51 single-chip drive to the four-wire drive displayed by LCD1602

     

    "/ this program has been debugged //Next, call the instance ////////////////////////////////// //LCD1602 read / write header file //Four wire drive mode ////////////////////////////////// #include #include “LCD1602.h” /*----------- Pins are defined in the LCD header file -----------*/ void main(void){ LCD_ init(); p=LCD_ PutStr(“Hello Lcd1602!\ n”,-1); // Display a text p=LCD_ PutNum(1234,2,p); // The number 12.34 is displayed while(1); } /*--------------------------------------------------------- LCD lcd1602c uses 4 data lines (D4 ~ D7) -----------------------------------------------------------*/ /*------------------------------------------------------------- LCD pin definition 1---GND 2---VCC 3---VO 4---RS 5---RW 6---EN 7 to 14 -- d0-d7 15 -- backlight+ 16 -- backlight- -----------------------------------------------------------------*/ #include #include Reference address: http://www.21ic.com/app/mcu/201812/784986.htm #define LCD_ DATA P2 sbit LCD1602_ RS=P2^2; sbit LCD1602_ EN=P2^3; int p=0; /*-------------------------------------------------------------------------------------------------- Function description --------------------------------------------------------------------------------------------------*/ void LCD_ init(void); void LCD_ en_ write(void); void LCD_ write_ command(unsigned char command) ; void LCD_ write_ data(unsigned char Recdata); void LCD_ set_ xy (unsigned char x, unsigned char y); void LCD_ write_ string(unsigned char X,unsigned char Y,unsigned char *s); void LCD_ write_ char(unsigned char X,unsigned char Y,unsigned char Recdata); void delay_ nus(unsigned int n); void delay_ nms(unsigned int n); void delay_ 1US (void) / / 1US delay function { _ nop_(); } void delay_ NUS (unsigned int n) / / n US delay function { unsigned int i=0; for (i=0; i delay_ 1us(); } void delay_ 1ms (void) / / 1ms delay function { unsigned int i; for (i=0; i《1140; i++); } void delay_ NMS (unsigned int n) / / N MS delay function { unsigned int i=0; for (i=0; i delay_ 1ms(); } void LCD_ Init (void) / / LCD initialization { LCD_ write_ command(0x28); delay_ nus(40); LCD_ write_ command(0x28); delay_ nus(40); LCD_ write_ command(0x28); delay_ nus(40); LCD_ en_ write(); delay_ nus(40); LCD_ write_ command(0x28); // 4-digit display LCD_ write_ command(0x0c); // Display on LCD_ write_ command(0x01); // Clear screen delay_ nms(2); } void LCD_ en_ Write (void) / / LCD enable { LCD1602_ EN=1; delay_ nus(1); LCD1602_ EN=0; } void LCD_ write_ Command (unsigned char command) / / write instruction { delay_ nus(16); LCD1602_ RS=0; // RS=0 LCD_ DATA&=0X0f; // Qinggao four LCD_ DATA|=command&0xf0; // Write four digits higher LCD_ en_ write(); command=command《《4; // Shift from low four to high four LCD_ DATA&=0x0f; // Qinggao four LCD_ DATA|=command&0xf0; // Write down four digits LCD_ en_ write(); } void LCD_ write_ Data (unsigned char recdata) / / write data { delay_ nus(16); LCD1602_ RS=1; // RS=1 LCD_ DATA&=0X0f; // Qinggao four LCD_ DATA|=Recdata&0xf0; // Write four digits higher LCD_ en_ write(); Recdata=Recdata《《4; // Shift from low four to high four LCD_ DATA&=0X0f; // Qinggao four LCD_ DATA|=Recdata&0xf0; // Write down four digits LCD_ en_ write(); } void LCD_ set_ XY (unsigned char x, unsigned char y) / / address writing function { unsigned char address; if (y == 0) address = 0x80 + x; else address = 0xc0 + x; LCD_ write_ command(address); } void LCD_ write_ Char (unsigned char x, unsigned char y, unsigned char recdata) / / column x = 0 ~ 15, row y = 0, 1 { LCD_ set_ xy(X, Y); // Write address LCD_ write_ data(Recdata); } int LCD_ PutStr(unsigned char *DData,int pos){ unsigned char i; if(pos==-1){ LCD_ write_ command(0x01); // Clear screen delay_ nms(2); pos=0; } while((*DData)!=‘\ 0’){ switch(*DData){ Case '\ n': / / if yes, wrap { if(pos《17){ for(i=pos; i《16; i++) LCD_ write_ char(i%16, i/16, ‘ ’); pos=16; } else{ for(i=pos; i《32; i++) LCD_ write_ char(i%16, i/16, ‘ ’); pos=32; } break; } Case '\ B': / / if it is \ B, backspace { if(pos》0) pos--; LCD_ write_ char(pos%16, pos/16, ‘ ’); break; } default: { if((*DData)《0x20){ *DData=‘ ’; } LCD_ write_ char(pos%16, pos/16,*DData); pos++; break; } } DData++; } return(pos); } //----------------------------The following functions are used to output numbers--------------------- int LCD_ Putnum (unsigned long num, int XS, int POS) {/ / count from the right and keep several decimal places unsigned long tmp=0; unsigned char numbits=0; if(pos==-1){ LCD_ write_ command(0x01); delay_ nms(2); pos=0; } if(num==0){ LCD_ write_ char(pos%16, pos/16, ‘0’); pos++; } else{ if(num《0){ LCD_ write_ char(pos%16, pos/16, ‘-’); num*=(-1); pos++; } while(num){ tmp=tmp*10+(num%10); num=num/10; numbits++; } while(tmp){ LCD_ write_ char(pos%16, pos/16, (tmp%10)+48); tmp=tmp/10; pos++; numbits--; if(numbits==XS) pos=LCD_ PutStr(“。”, pos); // Show decimal point } while(numbits--){ LCD_ write_ char(pos%16, pos/16, ‘0’); pos++; } } return(pos); }, read the full text, technical section Design of single chip microcomputer soft timer Four wire drive of LCD1602 display by 51 single chip microcomputer How to realize the one button switch function on stm8s single chip microcomputer What reset methods does 8051 single chip microcomputer have STM32 MCU TFTLCD driver design, Download enthusiast app Create an electronic circle of your contacts Pay attention to wechat of electronic enthusiasts Interesting and informative information and technology dry goods Focus on enthusiast class Lock in the latest course activities and technology live broadcast

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us