LCD1602_8 data

Publisher:温柔阳光Latest update time:2016-12-13 Source: eefocusKeywords:LCD1602  msp430g2553 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

         Programs should be written in their own style

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

** This is a 1602 program written when learning msp430g2553 microcontroller **

** Time is accurate to us, basically no garbled characters **

** P1 is the data output port **
** rs is connected to p2.1 **

** rw ground **
** en connect to p2.0 **

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

 

#include
#include

#define rs_0 P2OUT&=~BIT1
#define rs_1 P2OUT|=BIT1

#define en_0 P2OUT&=~BIT0
#define en_1 P2OUT|=BIT0
 char table_1[]={"SHOU BU NIAO L !"};
 char table_2[]={"2012.8.02"};
unsigned int num;
unsigned int con_1,con_2;

 

void LCD1602_write_command(unsigned int com)
{
 rs_0;
 P1OUT=com;
 __delay_cycles(500);
 en_1;
 __delay_cycles(500);
 en_0; 
}

 

void LCD1602_write_data(unsigned int dat)
{
 rs_1;
 P1OUT=dat;
 __delay_cycles(500);
 en_1;
 __delay_cycles(500);
 en_0;
}

 

void LCD1602_init()
 {
  LCD1602_write_command(0x38); //5*7 dot matrix, double line display
  LCD1602_write_command(0x0c); //0x0f has cursor,
  LCD1602_write_command(0x01); //Clear screen
  LCD1602_write_command(0x06); //After writing data, the cursor moves right and the display screen does not move
  LCD1602_write_command(0x80);
}

 

void main ()
{
 con_1=strlen(table_1);
 con_2=strlen(table_2);
 
 WDTCTL=WDTPW+WDTHOLD;
 
 P1DIR =0XFF;
 P2DIR=0XFF;
 
 LCD1602_init();
 
 for(num=0;num {
  LCD1602_write_data(table_1[num]);
  __delay_cycles(1000);
  }


 LCD1602_write_command(0x80+0x40);
 for(num=0;num {
   LCD1602_write_data(table_2[num]);
   __delay_cycles(1000);
 }


 while(1);
}


Keywords:LCD1602  msp430g2553 Reference address:LCD1602_8 data

Previous article:Keil Tutorial (II)
Next article:DS18b20 Temperature Detection Description

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号