arduino 4位数码管中怎么让数码管显示实时速度

基于模型的Arduino超声波测距及数码管显示_百度文库arduino DHT11和四位数码管,怎么编程才能让数码管交替显示温度湿度_百度知道
arduino DHT11和四位数码管,怎么编程才能让数码管交替显示温度湿度
这是DHT11温湿度的程序,温湿度的显示是在串口监视器里的,想问一下怎么改才能显示在四位数码管的前两位,DHT11的显示是16位字节的,怎么能改一下显示十进制呢?int DHpin = 8; byte dat[5]; byte read_data() {
for(int i=0; i&8; i++)
我有更好的答案
4x7-segment数码管通常都有驱动IC在内,不知你手上的是74HC595,还是MAX?若是没有驱动IC,那就更麻烦,要重新写一个字库驱动,会有点闪烁和延时。
是那种共阴四位数码管,不知道叫什么啊
74HC595的示例:MAX7219的示例:
都不是的啊,我去网上查了,应该是A5461AH,共阴四位数码管。
不建议用普通的共阴四位数码管,自行编写数字库会花很多时间,对日后扩展与程式维护都不太好,四位数码管的显示很会很闪烁。建议带有资料锁存功能的74HC595或MAX7219驱动数码管。
没关系,我只是做毕业设计,现在手头上的东西有限,只要能实现功能就可以
采纳率:83%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。【求教】求教一个数码管显示时间的代码【arduino吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:56,138贴子:
【求教】求教一个数码管显示时间的代码收藏
自己写了一段代码 想要显示二十四小时的时间 但是跳出来一个三十小时制 求解如何修改
arduino, 750多家厂商代理,100多万种现货库存,当天出货,免费送货.
代码如下//设置阴极接口int a = 1;int b = 2;int c = 3;int d = 4;int e = 5;int f = 6;int g = 7;int dp = 8;//设置阳极接口int d4 = 9;int d3 = 10;int d2 = 11;int d1 = 12;//设置变量long n = 0;long n10 = 0;long n100 = 0;long n1000 = 0;int x = 100;int del = 55;
//此处数值对时钟进行微调 byte segs[7] = { a, b, c, d, e, f, g }; byte seven_seg_digits[10][7] = { { 0,0,0,0,0,0,1 },
{ 1,0,0,1,1,1,1 },
{ 0,0,1,0,0,1,0 },
{ 0,0,0,0,1,1,0 },
{ 1,0,0,1,1,0,0 },
{ 0,1,0,0,1,0,0 },
{ 0,1,0,0,0,0,0 },
{ 0,0,0,1,1,1,1 },
{ 0,0,0,0,0,0,0 },
{ 0,0,0,0,1,0,0 }
}; byte seven_seg_digits2[6][7] = { { 0,0,0,0,0,0,1 },
{ 1,0,0,1,1,1,1 },
{ 0,0,1,0,0,1,0 },
{ 0,0,0,0,1,1,0 },
{ 1,0,0,1,1,0,0 },
{ 0,1,0,0,1,0,0 },
}; byte seven_seg_digits3[3][7] = { { 0,0,0,0,0,0,1 },
{ 1,0,0,1,1,1,1 },
{ 0,0,1,0,0,1,0 },
void setup(){
pinMode(d1, OUTPUT);
pinMode(d2, OUTPUT);
pinMode(d3, OUTPUT);
pinMode(d4, OUTPUT);
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(dp, OUTPUT);} void loop(){
long w = millis()/100;//这个是调用时间的函数
shownum(w);} void pickDigit(int x)
//定义pickDigit(x),其作用是开启dx端口{
digitalWrite(d1, LOW);
digitalWrite(d2, LOW);
digitalWrite(d3, LOW);
digitalWrite(d4, LOW);
digitalWrite(d1, HIGH);
digitalWrite(d2, HIGH);
digitalWrite(d3, HIGH);
digitalWrite(d4, HIGH);
}} void dispDec(int x)
//设定开启小数点{
digitalWrite(dp, LOW);} void clearLEDs()
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
digitalWrite(dp, HIGH);}
// 点亮对应数字的数码管void lightSegments(int x) {
for (int i = 0; i & 7; i++) {
digitalWrite(segs[i], seven_seg_digits[x][i]);
}}void lightSegments2(int x) {
for (int i = 0; i & 7; i++) {
digitalWrite(segs[i], seven_seg_digits2[x][i]);
}}void lightSegments3(int x) {
for (int i = 0; i & 7; i++) {
digitalWrite(segs[i], seven_seg_digits3[x][i]);
}} void shownum (int x){
long x1 = x/600%3;
long x10 = x/60%10;
long x100 = x/10%6;
long x1000 = x/1%10;
clearLEDs();
pickDigit(1);
lightSegments3(x1);
delayMicroseconds(del);
clearLEDs();
pickDigit(2);
dispDec(2);
lightSegments(x10);
delayMicroseconds(del);
clearLEDs();
pickDigit(3);
lightSegments2(x100);
delayMicroseconds(del);
clearLEDs();
pickDigit(0);
lightSegments(x1000);
delayMicroseconds(del);
clearLEDs();
pickDigit(0);
lightSegments(0);
delayMicroseconds(del);
clearLEDs();
pickDigit(1);
lightSegments3(0);;
delayMicroseconds(del);
因验证需要 后面的时间均调快 但是无法使23时后一小时显示为0时
求教如何修改
代码看不懂,怎么连接的,求指导
登录百度帐号同步各端记录
下载PC客户端,上传视频更轻松!
药品服务许可证(京)-经营-
请使用者仔细阅读优酷、、
Copyright(C)2017 优酷 youku.com 版权所有
不良信息举报电话:
Arduino 控制八段数码管显示数字
Arduino 控制八段数码管显示数字—在线播放—《Arduino 控制八段数码管显示数字》—科技—优酷网,视频高清在线观看
微信/手机 扫码分享
点击一下 网页分享
<input id="link4" type="text" class="fn-share-input" value="" data-spm-anchor-id="0.0.0.i1" />
复制通用代码
<input type="text" class="fn-share-input" id="link3" value="" />
复制Html代码
复制Flash代码
将启用PC客户端下载视频
Arduino 控制八段数码管显示数字
用优酷移动APP扫码
或用微信扫码观看
二维码2小时有效
没有客户端?扫码马上安装
IPHONE / 安卓
Arduino 控制八段数码管显示数字
使用HTML5播放器
使用FLASH播放器第37节:数码管作为仪表盘显示跑马灯的方向,速度和状态
09:51:21来源: eefocus 关键字:&&&&
& & 我在第24节中讲过按键控制的方向,速度和运行状态的项目程序,只可惜那个程序不能直观地显示运行中的三种状态,这节我决定在24节的基础上,增加一个显示作为类似汽车的界面,实时显示跑马灯的方向,速度,和运行状态。
这一节要教会大家一个知识点:继续加深理解运动,按键与数码管三者之间的关联程序框架。
具体内容,请看源代码讲解。
(1)硬件平台:
基于朱兆祺51单片机学习板。用S1键作为控制跑马灯的方向按键,S5键作为控制跑马灯方向的加速度按键,S9键作为控制跑马灯方向的减速度按键,S13键作为控制跑马灯方向的启动或者暂停按键。记得把输出线P0.4一直输出低电平,模拟独立按键的触发地GND。
(2)实现功能:
跑马灯运行:第1个至第8个LED灯一直不亮。在第9个至第16个LED灯,依次逐个亮灯并且每次只能亮一个灯。每按一次独立按键S13键,原来运行的跑马灯会暂停,原来暂停的跑马灯会运行。用S1来改变方向。用S5和S9来改变速度,每按一次按键的递增或者递减以10为单位。
数码管显示:本程序只有1个窗口,这个窗口分成3个局部显示。8,7,6位数码管显示运行状态,启动时显示&on&,停止时显示&oFF&。5位数码管显示数码管方向,正向显示&n&,反向显示&U&。4,3,2,1位数码管显示速度。数值越大速度越慢,最慢的速度是550,最快的速度是50。
(3)源代码讲解如下:
#include "REG52.H"
#define const_voice_short&&40& &//蜂鸣器短叫的持续时间
#define const_key_time1&&20& & //按键去抖动延时的时间
#define const_key_time2&&20& & //按键去抖动延时的时间
#define const_key_time3&&20& & //按键去抖动延时的时间
#define const_key_time4&&20& & //按键去抖动延时的时间
void initial_myself();& &&
void initial_peripheral();
void delay_short(unsigned int uiDelayShort);&
void delay_long(unsigned int uiDelaylong);
//驱动数码管的74HC595
void dig_hc595_drive(unsigned char ucDigStatusTemp16_09,unsigned char ucDigStatusTemp08_01);&&
void display_drive(); //显示数码管字模的驱动函数
void display_service(); //显示的窗口菜单服务程序
//驱动LED的74HC595
void hc595_drive(unsigned char ucLedStatusTemp16_09,unsigned char ucLedStatusTemp08_01);
void led_flicker_09_16(); //第9个至第16个LED的跑马灯程序,逐个亮并且每次只能亮一个.
void led_update();&&//LED更新函数
void T0_time();&&//定时中断函数
void key_service(); //按键服务的应用程序
void key_scan();//按键扫描函数 放在定时中断里
sbit beep_dr=P2^7; //蜂鸣器的驱动IO口
sbit key_sr1=P0^0; //对应朱兆祺学习板的S1键
sbit key_sr2=P0^1; //对应朱兆祺学习板的S5键
sbit key_sr3=P0^2; //对应朱兆祺学习板的S9键
sbit key_sr4=P0^3; //对应朱兆祺学习板的S13键
sbit key_gnd_dr=P0^4; //模拟独立按键的地GND,因此必须一直输出低电平
sbit led_dr=P3^5;&&
sbit dig_hc595_sh_dr=P2^0;& &&&//数码管的74HC595程序
sbit dig_hc595_st_dr=P2^1;&&
sbit dig_hc595_ds_dr=P2^2;&&
sbit hc595_sh_dr=P2^3;& & //LED灯的74HC595程序
sbit hc595_st_dr=P2^4;&&
sbit hc595_ds_dr=P2^5;&&
unsigned char ucKeySec=0;& &//被触发的按键编号
unsigned int&&uiKeyTimeCnt1=0; //按键去抖动延时计数器
unsigned char ucKeyLock1=0; //按键触发后自锁的变量标志
unsigned int&&uiKeyTimeCnt2=0; //按键去抖动延时计数器
unsigned char ucKeyLock2=0; //按键触发后自锁的变量标志
unsigned int&&uiKeyTimeCnt3=0; //按键去抖动延时计数器
unsigned char ucKeyLock3=0; //按键触发后自锁的变量标志
unsigned int&&uiKeyTimeCnt4=0; //按键去抖动延时计数器
unsigned char ucKeyLock4=0; //按键触发后自锁的变量标志
unsigned int&&uiVoiceCnt=0;&&//蜂鸣器鸣叫的持续时间计数器
unsigned char ucLed_dr1=0;& &//代表16个灯的亮灭状态,0代表灭,1代表亮
unsigned char ucLed_dr2=0;
unsigned char ucLed_dr3=0;
unsigned char ucLed_dr4=0;
unsigned char ucLed_dr5=0;
unsigned char ucLed_dr6=0;
unsigned char ucLed_dr7=0;
unsigned char ucLed_dr8=0;
unsigned char ucLed_dr9=0;
unsigned char ucLed_dr10=0;
unsigned char ucLed_dr11=0;
unsigned char ucLed_dr12=0;
unsigned char ucLed_dr13=0;
unsigned char ucLed_dr14=0;
unsigned char ucLed_dr15=0;
unsigned char ucLed_dr16=0;
unsigned char ucLed_update=0;&&//刷新变量。每次更改LED灯的状态都要更新一次。
unsigned char ucLedStep_09_16=0; //第9个至第16个LED跑马灯的步骤变量
unsigned int&&uiTimeCnt_09_16=0; //第9个至第16个LED跑马灯的统计定时中断次数的延时计数器
unsigned char ucLedStatus16_09=0;& &//代表底层74HC595输出状态的中间变量
unsigned char ucLedStatus08_01=0;& &//代表底层74HC595输出状态的中间变量
unsigned char ucLedDirFlag=0;& &//方向变量,把按键与跑马灯关联起来的核心变量,0代表正方向,1代表反方向
unsigned int&&uiSetTimeLevel_09_16=300;&&//速度变量,此数值越大速度越慢,此数值越小速度越快。
unsigned char ucLedStartFlag=1;& &//启动和暂停的变量,0代表暂停,1代表启动
unsigned char ucDigShow8;&&//第8位数码管要显示的内容
unsigned char ucDigShow7;&&//第7位数码管要显示的内容
unsigned char ucDigShow6;&&//第6位数码管要显示的内容
unsigned char ucDigShow5;&&//第5位数码管要显示的内容
unsigned char ucDigShow4;&&//第4位数码管要显示的内容
unsigned char ucDigShow3;&&//第3位数码管要显示的内容
unsigned char ucDigShow2;&&//第2位数码管要显示的内容
unsigned char ucDigShow1;&&//第1位数码管要显示的内容
unsigned char ucDigDot8;&&//数码管8的小数点是否显示的标志
unsigned char ucDigDot7;&&//数码管7的小数点是否显示的标志
unsigned char ucDigDot6;&&//数码管6的小数点是否显示的标志
unsigned char ucDigDot5;&&//数码管5的小数点是否显示的标志
unsigned char ucDigDot4;&&//数码管4的小数点是否显示的标志
unsigned char ucDigDot3;&&//数码管3的小数点是否显示的标志
unsigned char ucDigDot2;&&//数码管2的小数点是否显示的标志
unsigned char ucDigDot1;&&//数码管1的小数点是否显示的标志
unsigned char ucDigShowTemp=0; //临时中间变量
unsigned char ucDisplayDriveStep=1;&&//动态扫描数码管的步骤变量
unsigned char ucWd1Part1Update=1;&&//窗口1的局部1更新显示变量
unsigned char ucWd1Part2Update=1;&&//窗口1的局部2更新显示变量
unsigned char ucWd1Part3Update=1;&&//窗口1的局部3更新显示变量
//根据原理图得出的共阴数码管字模表
code unsigned char dig_table[]=
0x3f,&&//0& && & 序号0
0x06,&&//1& && & 序号1
0x5b,&&//2& && & 序号2
0x4f,&&//3& && & 序号3
0x66,&&//4& && & 序号4
0x6d,&&//5& && & 序号5
0x7d,&&//6& && & 序号6
0x07,&&//7& && & 序号7
0x7f,&&//8& && & 序号8
0x6f,&&//9& && & 序号9
0x00,&&//无& && &序号10
0x40,&&//-& && & 序号11
0x73,&&//P& && & 序号12
0x5c,&&//o& && & 序号13
0x71,&&//F& && & 序号14
0x3e,&&//U& && & 序号15
0x37,&&//n& && & 序号16
void main()&
& &initial_myself();&&
& &delay_long(100);& &
& &initial_peripheral();&
& &while(1)&&
& && &key_service(); //按键服务的应用程序
& && &display_service(); //显示的窗口菜单服务程序
& && &led_flicker_09_16(); //第9个至第16个LED的跑马灯程序,逐个亮并且每次只能亮一个.
& & & && &led_update();&&//LED更新函数
/* 注释一:
* 由于本程序只有1个窗口,而这个窗口又分成3个局部,因此可以省略去窗口变量uWd,
* 只用三个局部变量ucWdxPartyUpdate就可以了。
void display_service() //显示的窗口菜单服务程序
& & if(ucWd1Part1Update==1) //更新显示当前系统是处于运行还是暂停的状态
& && & ucWd1Part1Update=0; //及时把更新变量清零,防止一直进来更新
& & & && & if(ucLedStartFlag==1)&&//启动,显示on
& & & && & {
& & & && && &&&ucDigShow8=13;&&//显示o
& && && &&&ucDigShow7=16;&&//显示n
& && && &&&ucDigShow6=10;&&//显示空
& & & && & }
& & & && & else&&//暂停,显示oFF
& & & && & {
& & & && & & & & && & ucDigShow8=13;&&//显示o
& && && &&&ucDigShow7=14;&&//显示F
& && && &&&ucDigShow6=14;&&//显示F
& & & && & }
& & if(ucWd1Part2Update==1) //更新显示当前系统是处于正方向还是反方向
& && & ucWd1Part2Update=0; //及时把更新变量清零,防止一直进来更新
& & & && & if(ucLedDirFlag==0)&&//正方向,向上,显示n
& & & && & {
& & & && && &&&ucDigShow5=16;&&//显示n
& & & && & }
& & & && & else&&//反方向,向下,显示U
& & & && & {
& & & && && &&&ucDigShow5=15;&&//显示U
& & & && & }
& & if(ucWd1Part3Update==1) //更新显示当前系统的速度,此数值越大速度越慢,此数值越小速度越快。
& && & ucWd1Part3Update=0; //及时把更新变量清零,防止一直进来更新
& & & && & ucDigShow4=10;&&//显示空&&这一位不用,作为空格
& & & && & if(uiSetTimeLevel_09_16>=100)
& & & && & {
& && && & ucDigShow3=uiSetTimeLevel_09_16/100;& &&&//显示速度的百位
& & & && & }
& & & && & else
& & & && & {
& && && & ucDigShow3=10;& &&&//显示空
& & & && & }
& & & && & if(uiSetTimeLevel_09_16>=10)
& & & && & {
& && && & ucDigShow2=uiSetTimeLevel_09_16%100/10;&&//显示速度的十位
& & & && & }
& & & && & else
& & & && & {
& && && & ucDigShow2=10;& &&&//显示空
& & & && & }
& && & ucDigShow1=uiSetTimeLevel_09_16%10;& && &//显示速度的个位
void key_scan()//按键扫描函数 放在定时中断里
&&if(key_sr1==1)//IO是高电平,说明按键没有被按下,这时要及时清零一些标志位
& &&&ucKeyLock1=0; //按键自锁标志清零
& &&&uiKeyTimeCnt1=0;//按键去抖动延时计数器清零,此行非常巧妙,是我实战中摸索出来的。& && &
&&else if(ucKeyLock1==0)//有按键按下,且是第一次被按下
& &&&uiKeyTimeCnt1++; //累加定时中断次数
& &&&if(uiKeyTimeCnt1>const_key_time1)
& && &&&uiKeyTimeCnt1=0;&
& && &&&ucKeyLock1=1;&&//自锁按键置位,避免一直触发
& && &&&ucKeySec=1;& & //触发1号键
&&if(key_sr2==1)//IO是高电平,说明按键没有被按下,这时要及时清零一些标志位
& &&&ucKeyLock2=0; //按键自锁标志清零
& &&&uiKeyTimeCnt2=0;//按键去抖动延时计数器清零,此行非常巧妙,是我实战中摸索出来的。& && &
&&else if(ucKeyLock2==0)//有按键按下,且是第一次被按下
& &&&uiKeyTimeCnt2++; //累加定时中断次数
& &&&if(uiKeyTimeCnt2>const_key_time2)
& && &&&uiKeyTimeCnt2=0;&
& && &&&ucKeyLock2=1;&&//自锁按键置位,避免一直触发
& && &&&ucKeySec=2;& & //触发2号键
&&if(key_sr3==1)//IO是高电平,说明按键没有被按下,这时要及时清零一些标志位
& &&&ucKeyLock3=0; //按键自锁标志清零
& &&&uiKeyTimeCnt3=0;//按键去抖动延时计数器清零,此行非常巧妙,是我实战中摸索出来的。& && &
&&else if(ucKeyLock3==0)//有按键按下,且是第一次被按下
& &&&uiKeyTimeCnt3++; //累加定时中断次数
& &&&if(uiKeyTimeCnt3>const_key_time3)
& && &&&uiKeyTimeCnt3=0;&
& && &&&ucKeyLock3=1;&&//自锁按键置位,避免一直触发
& && &&&ucKeySec=3;& & //触发3号键
&&if(key_sr4==1)//IO是高电平,说明按键没有被按下,这时要及时清零一些标志位
& &&&ucKeyLock4=0; //按键自锁标志清零
& &&&uiKeyTimeCnt4=0;//按键去抖动延时计数器清零,此行非常巧妙,是我实战中摸索出来的。& && &
&&else if(ucKeyLock4==0)//有按键按下,且是第一次被按下
& &&&uiKeyTimeCnt4++; //累加定时中断次数
& &&&if(uiKeyTimeCnt4>const_key_time4)
& && &&&uiKeyTimeCnt4=0;&
& && &&&ucKeyLock4=1;&&//自锁按键置位,避免一直触发
& && &&&ucKeySec=4;& & //触发4号键
void key_service() //按键服务的应用程序
&&switch(ucKeySec) //按键服务状态切换
& & case 1:// 改变跑马灯方向的按键 对应朱兆祺学习板的S1键&
& && && & if(ucLedDirFlag==0) //通过中间变量改变跑马灯的方向
& & & & & & & && &{
& & & & & & & && && &ucLedDirFlag=1;
& & & & & & & && &}
& & & & & & & && &else
& & & & & & & && &{
& & & & & & & && && & & &&&ucLedDirFlag=0;
& & & & & & & && &}
& && && & ucWd1Part2Update=1; //及时更新显示方向
& && && & uiVoiceCnt=const_voice_ //按键声音触发,滴一声就停。
& && && & ucKeySec=0;&&//响应按键服务处理程序后,按键编号清零,避免一致触发
& && && && &&
& & case 2:// 加速按键 对应朱兆祺学习板的S5键 uiSetTimeLevel_09_16越小速度越快
& && && & uiSetTimeLevel_09_16=uiSetTimeLevel_09_16-10;
& & & & & & & && &if(uiSetTimeLevel_09_16<50)&&//最快限定在50
& & & & & & & && &{
& & & & & & & && && & uiSetTimeLevel_09_16=50;
& & & & & & & && &}
& && && & ucWd1Part3Update=1; //及时更新显示速度
& && && & uiVoiceCnt=const_voice_ //按键声音触发,滴一声就停。
& && && & ucKeySec=0;&&//响应按键服务处理程序后,按键编号清零,避免一致触发
& && && &&&
& & case 3:// 减速按键 对应朱兆祺学习板的S9键&&uiSetTimeLevel_09_16越大速度越慢
& && && & uiSetTimeLevel_09_16=uiSetTimeLevel_09_16+10;
& & & & & & & && &if(uiSetTimeLevel_09_16>550)&&//最慢限定在550
& & & & & & & && &{
& & & & & & & && && & uiSetTimeLevel_09_16=550;
& & & & & & & && &}
& && && & ucWd1Part3Update=1; //及时更新显示速度
& && && & uiVoiceCnt=const_voice_ //按键声音触发,滴一声就停。
& && && & ucKeySec=0;&&//响应按键服务处理程序后,按键编号清零,避免一致触发
& && && && && && &
& & case 4:// 启动和暂停按键 对应朱兆祺学习板的S13键&&ucLedStartFlag为0时代表暂停,为1时代表启动
& & & && && & if(ucLedStartFlag==1)&&//启动和暂停两种状态循环切换
& & & & & & & && &{
& & & & & & & && && &ucLedStartFlag=0;
& & & & & & & && &}
& & & & & & & && &else& && && && && && & //启动和暂停两种状态循环切换
& & & & & & & && &{
& & & & & & & && && & & &&&ucLedStartFlag=1;
& & & & & & & && &}
& && && & ucWd1Part1Update=1; //及时更新显示系统的运行状态,是运行还是暂停.
& && && & uiVoiceCnt=const_voice_ //按键声音触发,滴一声就停。
& && && & ucKeySec=0;&&//响应按键服务处理程序后,按键编号清零,避免一致触发
& && && && &&
&&}& && && && && &&
void led_update()&&//LED更新函数
& &if(ucLed_update==1)
& && & ucLed_update=0;& &//及时清零,让它产生只更新一次的效果,避免一直更新。
& && & if(ucLed_dr1==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x01;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0
& & & && & }
& && & if(ucLed_dr2==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x02;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0
& & & && & }
& && & if(ucLed_dr3==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x04;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0
& & & && & }
& && & if(ucLed_dr4==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x08;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0xf7;
& & & && & }
& && & if(ucLed_dr5==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x10;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0
& & & && & }
& && & if(ucLed_dr6==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x20;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0
& & & && & }
& && & if(ucLed_dr7==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x40;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0
& & & && & }
& && & if(ucLed_dr8==1)
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01|0x80;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus08_01=ucLedStatus08_01&0x7f;
& & & && & }
& && & if(ucLed_dr9==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x01;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0
& & & && & }
& && & if(ucLed_dr10==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x02;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0
& & & && & }
& && & if(ucLed_dr11==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x04;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0
& & & && & }
& && & if(ucLed_dr12==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x08;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0xf7;
& & & && & }
& && & if(ucLed_dr13==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x10;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0
& & & && & }
& && & if(ucLed_dr14==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x20;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0
& & & && & }
& && & if(ucLed_dr15==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x40;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0
& & & && & }
& && & if(ucLed_dr16==1)
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09|0x80;
& & & && & }
& & & && & else
& & & && & {
& & & && && & ucLedStatus16_09=ucLedStatus16_09&0x7f;
& & & && & }
& && & hc595_drive(ucLedStatus16_09,ucLedStatus08_01);&&//74HC595底层驱动函数
void display_drive()&&
& &//以下程序,如果加一些数组和移位的元素,还可以压缩容量。但是鸿哥追求的不是容量,而是清晰的讲解思路
& &switch(ucDisplayDriveStep)
& && &case 1:&&//显示第1位
& && && &&&ucDigShowTemp=dig_table[ucDigShow1];
& && && && && && & if(ucDigDot1==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && && && && & }
& && && &&&dig_hc595_drive(ucDigShowTemp,0xfe);
& && && && && &
& && &case 2:&&//显示第2位
& && && &&&ucDigShowTemp=dig_table[ucDigShow2];
& && && && && && & if(ucDigDot2==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && && && && & }
& && && &&&dig_hc595_drive(ucDigShowTemp,0xfd);
& && && && && &
& && &case 3:&&//显示第3位
& && && &&&ucDigShowTemp=dig_table[ucDigShow3];
& && && && && && & if(ucDigDot3==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && && && && & }
& && && &&&dig_hc595_drive(ucDigShowTemp,0xfb);
& && && && && &
& && &case 4:&&//显示第4位
& && && &&&ucDigShowTemp=dig_table[ucDigShow4];
& && && && && && & if(ucDigDot4==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && && && && & }
& && && &&&dig_hc595_drive(ucDigShowTemp,0xf7);
& && && && && &
& && &case 5:&&//显示第5位
& && && &&&ucDigShowTemp=dig_table[ucDigShow5];
& && && && && && & if(ucDigDot5==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && && && && & }
& && && &&&dig_hc595_drive(ucDigShowTemp,0xef);
& && && && && &
& && &case 6:&&//显示第6位
& && && &&&ucDigShowTemp=dig_table[ucDigShow6];
& && && && && && & if(ucDigDot6==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && && && && & }
& && && &&&dig_hc595_drive(ucDigShowTemp,0xdf);
& && && && && &
& && &case 7:&&//显示第7位
& && && &&&ucDigShowTemp=dig_table[ucDigShow7];
& && && && && && & if(ucDigDot7==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && &&&}
& && && &&&dig_hc595_drive(ucDigShowTemp,0xbf);
& && && && && &
& && &case 8:&&//显示第8位
& && && &&&ucDigShowTemp=dig_table[ucDigShow8];
& && && && && && & if(ucDigDot8==1)
& && && && && && & {
& && && && && && && & ucDigShowTemp=ucDigShowTemp|0x80;&&//显示小数点
& && && && && && & }
& && && &&&dig_hc595_drive(ucDigShowTemp,0x7f);
& && && && && &
& &ucDisplayDriveStep++;
& &if(ucDisplayDriveStep>8)&&//扫描完8个数码管后,重新从第一个开始扫描
& &&&ucDisplayDriveStep=1;
//数码管的74HC595驱动函数
void dig_hc595_drive(unsigned char ucDigStatusTemp16_09,unsigned char ucDigStatusTemp08_01)
& &unsigned char ucTempD
& &dig_hc595_sh_dr=0;
& &dig_hc595_st_dr=0;
& &ucTempData=ucDigStatusTemp16_09;&&//先送高8位
& &for(i=0;i<8;i++)
& && && &if(ucTempData>=0x80)dig_hc595_ds_dr=1;
& && && &else dig_hc595_ds_dr=0;
& && && &dig_hc595_sh_dr=0;& &&&//SH引脚的上升沿把数据送入寄存器
& && && &delay_short(1);&
& && && &dig_hc595_sh_dr=1;
& && && &delay_short(1);&
& && && &ucTempData=ucTempData<<1;
& &ucTempData=ucDigStatusTemp08_01;&&//再先送低8位
& &for(i=0;i<8;i++)
& && && &if(ucTempData>=0x80)dig_hc595_ds_dr=1;
& && && &else dig_hc595_ds_dr=0;
& && && &dig_hc595_sh_dr=0;& &&&//SH引脚的上升沿把数据送入寄存器
& && && &delay_short(1);&
& && && &dig_hc595_sh_dr=1;
& && && &delay_short(1);&
& && && &ucTempData=ucTempData<<1;
& &dig_hc595_st_dr=0;&&//ST引脚把两个寄存器的数据更新输出到74HC595的输出引脚上并且锁存起来
& &delay_short(1);&
& &dig_hc595_st_dr=1;
& &delay_short(1);&
& &dig_hc595_sh_dr=0;& & //拉低,抗干扰就增强
& &dig_hc595_st_dr=0;
& &dig_hc595_ds_dr=0;
//LED灯的74HC595驱动函数
void hc595_drive(unsigned char ucLedStatusTemp16_09,unsigned char ucLedStatusTemp08_01)
& &unsigned char ucTempD
& &hc595_sh_dr=0;
& &hc595_st_dr=0;
& &ucTempData=ucLedStatusTemp16_09;&&//先送高8位
& &for(i=0;i<8;i++)
& && && &if(ucTempData>=0x80)hc595_ds_dr=1;
& && && &else hc595_ds_dr=0;
& && && &hc595_sh_dr=0;& &&&//SH引脚的上升沿把数据送入寄存器
& && && &delay_short(1);&
& && && &hc595_sh_dr=1;
& && && &delay_short(1);&
& && && &ucTempData=ucTempData<<1;
& &ucTempData=ucLedStatusTemp08_01;&&//再先送低8位
& &for(i=0;i<8;i++)
& && && &if(ucTempData>=0x80)hc595_ds_dr=1;
& && && &else hc595_ds_dr=0;
& && && &hc595_sh_dr=0;& &&&//SH引脚的上升沿把数据送入寄存器
& && && &delay_short(1);&
& && && &hc595_sh_dr=1;
& && && &delay_short(1);&
& && && &ucTempData=ucTempData<<1;
& &hc595_st_dr=0;&&//ST引脚把两个寄存器的数据更新输出到74HC595的输出引脚上并且锁存起来
& &delay_short(1);&
& &hc595_st_dr=1;
& &delay_short(1);&
& &hc595_sh_dr=0;& & //拉低,抗干扰就增强
& &hc595_st_dr=0;
& &hc595_ds_dr=0;
void led_flicker_09_16() //第9个至第16个LED的跑马灯程序,逐个亮并且每次只能亮一个.
&&if(ucLedStartFlag==1)&&//此变量为1时代表启动
& &&&switch(ucLedStep_09_16)
& &&&case 0:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr16=0;&&//第16个灭
& && && && && && &ucLed_dr9=1;&&//第9个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=1; //切换到下一个步骤
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr15=1;&&//第15个亮
& && && && && && &ucLed_dr16=0;&&//第16个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=7; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
& &&&case 1:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr9=0;&&//第9个灭
& && && && && && &ucLed_dr10=1;&&//第10个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=2; //切换到下一个步骤
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr16=1;&&//第16个亮
& && && && && && &ucLed_dr9=0;&&//第9个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=0; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
& &&&case 2:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr10=0;&&//第10个灭
& && && && && && &ucLed_dr11=1;&&//第11个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=3; //切换到下一个步骤
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr9=1;&&//第9个亮
& && && && && && &ucLed_dr10=0;&&//第10个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=1; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
& &&&case 3:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr11=0;&&//第11个灭
& && && && && && &ucLed_dr12=1;&&//第12个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=4; //切换到下一个步骤
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr10=1;&&//第10个亮
& && && && && && &ucLed_dr11=0;&&//第11个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=2; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
& &&&case 4:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr12=0;&&//第12个灭
& && && && && && &ucLed_dr13=1;&&//第13个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=5; //切换到下一个步骤
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr11=1;&&//第11个亮
& && && && && && &ucLed_dr12=0;&&//第12个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=3; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
& &&&case 5:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr13=0;&&//第13个灭
& && && && && && &ucLed_dr14=1;&&//第14个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=6; //切换到下一个步骤
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr12=1;&&//第12个亮
& && && && && && &ucLed_dr13=0;&&//第13个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=4; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
& &&&case 6:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr14=0;&&//第14个灭
& && && && && && &ucLed_dr15=1;&&//第15个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=7; //切换到下一个步骤
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr13=1;&&//第13个亮
& && && && && && &ucLed_dr14=0;&&//第14个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=5; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
& &&&case 7:
& && && &&&if(uiTimeCnt_09_16>=uiSetTimeLevel_09_16) //时间到
& && && &&&{
& && && && && &uiTimeCnt_09_16=0; //时间计数器清零
& & & & & & & & & & & && & if(ucLedDirFlag==0)&&//正方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr15=0;&&//第15个灭
& && && && && && &ucLed_dr16=1;&&//第16个亮
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=0; //返回到开始处,重新开始新的一次循环
& & & & & & & & & & & && & }
& & & & & & & & & & & && & else&&//反方向
& & & & & & & & & & & && & {
& && && && && && &ucLed_dr14=1;&&//第14个亮
& && && && && && &ucLed_dr15=0;&&//第15个灭
& && && && && && &ucLed_update=1;&&//更新显示
& && && && && && &ucLedStep_09_16=6; //返回上一个步骤
& & & & & & & & & & & && & }
& && && &&&}
& && && &&&
void T0_time() interrupt 1
&&TF0=0;&&//清除中断标志
&&TR0=0; //关中断
&&if(uiTimeCnt_09_16<0xffff)&&//设定这个条件,防止uiTimeCnt超范围。
& && &if(ucLedStartFlag==1)&&//此变量为1时代表启动
& & & && &{
& && && &uiTimeCnt_09_16++;&&//累加定时中断的次数,
& & & && &}
&&key_scan(); //按键扫描函数
&&if(uiVoiceCnt!=0)
& &&&uiVoiceCnt--; //每次进入定时中断都自减1,直到等于零为止。才停止鸣叫
& &&&beep_dr=0;&&//蜂鸣器是PNP三极管控制,低电平就开始鸣叫。
//& &&&beep_dr=1;&&//蜂鸣器是PNP三极管控制,低电平就开始鸣叫。
& &&&; //此处多加一个空指令,想维持跟if括号语句的数量对称,都是两条指令。不加也可以。
& &&&beep_dr=1;&&//蜂鸣器是PNP三极管控制,高电平就停止鸣叫。
//& &&&beep_dr=0;&&//蜂鸣器是PNP三极管控制,高电平就停止鸣叫。
&&display_drive();&&//数码管字模的驱动函数
&&TH0=0& &//重装初始值()=65035=0xfe0b
&&TL0=0x0b;
&&TR0=1;&&//开中断
void delay_short(unsigned int uiDelayShort)&
& &for(i=0;i<uiDelaySi++)
& &&&;& &//一个分号相当于执行一条空语句
void delay_long(unsigned int uiDelayLong)
& &for(i=0;i<uiDelayLi++)
& && &for(j=0;j<500;j++)&&//内嵌循环的空指令数量
& && && & {
& && && && & ; //一个分号相当于执行一条空语句
& && && & }
void initial_myself()&&//第一区 初始化单片机
/* 注释二:
* 矩阵键盘也可以做独立按键,前提是把某一根公共输出线输出低电平,
* 模拟独立按键的触发地,本程序中,把key_gnd_dr输出低电平。
* 朱兆祺51学习板的S1就是本程序中用到的一个独立按键。
&&key_gnd_dr=0; //模拟独立按键的地GND,因此必须一直输出低电平
&&led_dr=0;&&//关闭独立LED灯
&&beep_dr=1; //用PNP三极管控制蜂鸣器,输出高电平时不叫。
&&TMOD=0x01;&&//设置定时器0为工作方式1
&&TH0=0& &//重装初始值()=65035=0xfe0b
&&TL0=0x0b;
void initial_peripheral() //第二区 初始化外围
& &ucDigDot8=0;& &//小数点全部不显示
& &ucDigDot7=0;&&
& &ucDigDot6=0;&
& &ucDigDot5=0;&&
& &ucDigDot4=0;&
& &ucDigDot3=0;&&
& &ucDigDot2=0;
& &ucDigDot1=0;&
& &EA=1;& &&&//开总中断
& &ET0=1;& & //允许定时中断
& &TR0=1;& & //启动定时中断
总结陈词:
& & 前面花了大量的章节在讲数码管显示,按键,运动的关联程序框架,从下一节开始,我将会用八节内容来讲我常用的串口程序框架,内容非常精彩和震撼,思路非常简单而又实用。欲知详情,请听下回分解-----判断数据尾来接收一串数据的串口通用程序框架。
关键字:&&&&
编辑:什么鱼
引用地址:
本网站转载的所有的文章、图片、音频视频文件等资料的版权归版权所有人所有,本站采用的非本站原创文章及图片等内容无法一一联系确认版权者。如果本网所选内容的文章作者及编辑认为其作品不宜公开自由传播,或不应无偿使用,请及时通过电子邮件或电话通知我们,以迅速采取适当措施,避免给双方造成不必要的经济损失。
关注eeworld公众号快捷获取更多信息
关注eeworld服务号享受更多官方福利
网友正在学习IC视频
EEWORLD网友正在观看&&视频
EEWORLD网友正在观看&&视频
EEWORLD网友正在观看&&视频
EEWORLD网友正在观看&&视频
EEWORLD网友正在观看&&视频
相关关键词
热门关键词
大学堂最新课程
汇总了TI汽车信息娱乐系统方案、优质音频解决方案、汽车娱乐系统和仪表盘参考设计相关的文档、视频等资源
热门资源推荐
频道白皮书
何立民专栏
北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。}

我要回帖

更多关于 arduino四位数码管 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信