用户名
UID
Email
自动登录
找回密码
密码
登录
立即注册
首页
Portal
论坛
BBS
下载
官方淘宝店
搜索
万博网页版登陆页派论坛
»
论坛
›
电子世界论坛
›
电子综合区
›
pcDuino连结16 x 2 LCD屏 Shield
返回列表
pcDuino连结16 x 2 LCD屏 Shield
树老大
发表于 2013-5-16 22:42:58
|
显示全部楼层
|
阅读模式
http://player.youku.com/player.php/sid/XNTIzNjE2NjA4/v.swf
#include "core.h"
#define RS 8
#define EN 9
#define backlight 10
#define RS_L digitalWrite(RS,LOW)
#define RS_H digitalWrite(RS,HIGH)
#define EN_L digitalWrite(EN,LOW)
#define EN_H digitalWrite(EN,HIGH)
int DB[] = {7,6,5,4};
/********************************************************************/
void write_command(int command)
{
int i,temp;
RS_L;
EN_L;
temp=command & 0xf0;
for (i=0; i < 4; i++)
{
if(temp&0x80)
digitalWrite(DB[i],HIGH);
else digitalWrite(DB[i],LOW);
temp <<= 1;
}
EN_H;
delayMicroseconds(1);
EN_L;
temp=(command & 0x0f)<<4;
for (i=0; i < 4; i++)
{
if(temp&0x80)
digitalWrite(DB[i],HIGH);
else digitalWrite(DB[i],LOW);
temp <<= 1;
}
EN_H;
delayMicroseconds(1);
EN_L;
}
/********************************************************************/
void write_data(int dat)
{
int i=0,temp;
RS_H;
EN_L;
temp=dat & 0xf0;
for (i=0; i < 4; i++)
{
if(temp&0x80)
digitalWrite(DB[i],HIGH);
else digitalWrite(DB[i],LOW);
temp <<= 1;
}
EN_H;
delayMicroseconds(1);
EN_L;
temp=(dat & 0x0f)<<4;
for (i=0; i < 4; i++)
{
if(temp&0x80)
digitalWrite(DB[i],HIGH);
else digitalWrite(DB[i],LOW);
temp <<= 1;
}
EN_H;
delayMicroseconds(1);
EN_L;
}
/********************************************************************/
void LCD_write_char( int x,int y,int dat)
{
int address;
if (x ==0) address = 0x80 + y;
else address = 0xC0 + y;
write_command(address);
write_data(dat);
delayMicroseconds(10);
}
/********************************************************************/
void lcd1602_init()
{
int i = 0;
pinMode(RS,OUTPUT);
pinMode(EN,OUTPUT);
pinMode(backlight,OUTPUT);
digitalWrite(backlight,HIGH);
for (i=0; i < 4; i++)
{
pinMode(DB[i],OUTPUT);
}
delay(100);
write_command(0x28);
delay(50);
write_command(0x06);
delay(50);
write_command(0x0c);
delay(50);
write_command(0x80);
delay(50);
write_command(0x01);
delay(100);
}
/********************************************************************/
void setup (void)
{
lcd1602_init();
}
/********************************************************************/
void loop (void)
{
write_command(0x02);
delay(10);
LCD_write_char(0,2,'W');
LCD_write_char(0,3,'e');
LCD_write_char(0,4,'l');
LCD_write_char(0,5,'c');
LCD_write_char(0,6,'o');
LCD_write_char(0,7,'m');
LCD_write_char(0,8,'e');
LCD_write_char(0,10,'t');
LCD_write_char(0,11,'o');
LCD_write_char(1,4,'p');
LCD_write_char(1,5,'c');
LCD_write_char(1,6,'D');
LCD_write_char(1,7,'u');
LCD_write_char(1,8,'i');
LCD_write_char(1,9,'n');
LCD_write_char(1,10,'o');
while(1);
}
复制代码
joejoe
发表于 2013-12-15 13:35:31
|
显示全部楼层
请问楼主这块1602LCD Keypad怎么和万博网页版登陆页派相连
mouselt
发表于 2014-4-9 19:43:36
|
显示全部楼层
感谢楼主分享
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
手机版
|
Archiver
|
万博网页版登陆页派论坛
(
粤ICP备15075382号-1
)