欢迎来到装配图网! | 帮助中心 装配图网zhuangpeitu.com!
装配图网
ImageVerifierCode 换一换
首页 装配图网 > 资源分类 > DOC文档下载
 

单片机程序源代码[共43页]

  • 资源ID:154880616       资源大小:295.54KB        全文页数:43页
  • 资源格式: DOC        下载积分:12积分
快捷下载 游客一键下载
会员登录下载
微信登录下载
三方登录下载: 微信开放平台登录 支付宝登录   QQ登录   微博登录  
二维码
微信扫一扫登录
下载资源需要12积分
邮箱/手机:
温馨提示:
用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
支付方式: 支付宝    微信支付   
验证码:   换一换

 
账号:
密码:
验证码:   换一换
  忘记密码?
    
友情提示
2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

单片机程序源代码[共43页]

LED (D0 和 D1 ),编写程序,实现两个#define uint unsigned int#define uchar unsigned char#define uchar unsigned char D0 和 D7 灭,其次是 D1 和 D6 灭,再是 D2#define uchar unsigned char uint i,j,xx2=0xaa,0xff,yy2=0xf0,0x0f,zz2=0xb6,0xff; LED 数码管,编写程序,使数码管循环显示从#define uchar unsigned char #define uint unsigned int#define uchar unsigned chardelay(ms) #define uchar unsigned charcase 0xfe:case 0xfd:case 0xfb:case 0xf7:case 0xef:case 0xdf:case 0xbf:case 0x7f:#define uchar unsigned char uchar i,j;P2=0xf0;temp=P2;temp&=0xf0;switch(temp)case 0xe0:num=1;break;case 0xd0:num=2;break;case 0xb0:num=3;break;case 0x70:num=4;switch(temp)case 0xe0:num=5;break;case 0xd0:num=6;break;case 0xb0:num=7;break;case 0x70:num=8;case 0xe0:num=9;break; if(num=0)P0=0xbf;#define uchar unsigned char#define uint unsigned intsbit LED1=P20;sbit LED2=P21; uchar code LED_code=uchar i,j;uchar temp;P1=0xfe;/key1-key4 第一行按下temp=P1;switch(temp) switch(temp) switch(temp)temp=P1;switch(temp) 时,8 位数码管均显示 “-”,每按下一个号码后,原位。8 位 LED 数码管显示的内容向左移动#define uint unsigned int#define uchar unsigned charuchar keycount=0,num;uchar code LED1_code= uchar LED2_wei8= 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01;uchar i,j;switch(temp)case 0xee:keycount+;num=0;break;case 0xde:keycount+;num=1;break;case 0xbe:keycount+;num=2;break;case 0x7e:keycount+;num=3;break; temp=P3;switch(temp)case 0xed:keycount+;num=4;break;case 0xdd:keycount+;num=5;break;case 0xbd:keycount+;num=6;break;case 0x7d:keycount+;num=7;break; switch(temp)case 0xeb:keycount+;num=8;break;temp=P3;switch(temp) for(i=0;i<7;i+)LED2_duani=LED2_duani+1;后,8 只 LED 暂停默认显示,而进行闪烁显示,当显示达到5 次后,继续按默认规律显示。#define uint unsigned int#define uchar unsigned charvoid LED_shan() interrupt 0 P0 端口作为输出口,外接条形2 次按下按键 K 后,LED /将 led 值映射到 LED 灯delayms(500); /延时 500msvoid delayms(unsigned int ms)EX0 = 1; / 打开外部中断 0EA = 1; /打开总中断t = 0; #include<reg52.h>/ 头文件#define uchar unsigned char#define uint unsigned intuchar temp,key_count;uchar code tab= case 0:loop_leftmove();break;case 1:loop_rightmove();break;case 2:open_close();break;default:break;void key_interrupt() interrupt 0/ 外部中断 INT0 中断服务程序key_count+;key_count%=3;/*if(key_count=3)key_count=0;*/P0 端口作为输出口,外接#define uchar unsigned char#define uint unsigned intsbit key1=P32;sbit key2=P33;sbit beep=P10; EX0=1;/ 打开外部中断 INT0EX1=1;/ 打开外部中断 INT1 switch(key_count%2)case 1:left_right_move();break;/奇数次按键左移右移显示case 0:break;/偶数次按键拉幕式显示 P0 端口作为输出口,外接#define uchar unsigned char #define uchar unsigned charuchar key1=0,key2=0,m,n,k;uchar table=0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f; 使用单片机 P0、P2 端口作为输出口,外接一个#include<reg52.h>/ 头文件shi=count/10;/ 分离十位ge=count%10;/ 分离个位P2=tablege;/ 显示个位P0=tableshi;/ 显示十位 #include<reg52.h>/ 头文件void delay(uint ms)/ 延时子函数 使用单片机 P0、P2 端口作为输出口,外接一个K2 时,暂停加 1 计数,按键 K13 次按下按键 K2 时,LED 数码管显示为 0;第 4 TMOD=0x05;/ 设置工作方式为 1 选择计数效用TH0=0xff; #define uchar unsigned char #define uchar unsigned char任务三:用 T2 实现流水灯控制#include<reg52.h>/ 头文件 ET2=1;/ 打开定时器 2 中断TR2=1;/ 启动定时器 2init();/ 调用初始化函数while(1);void Timer2() interrupt 5 /T2 定时器的中断服务子程序TF2=0; /溢出标志位软件清零#include<reg52.h>#define uchar unsigned char#define uint unsigned intuchar code table= ET0=1;/ 打开定时器 0 中断TR0=1; / 启动定时器 0while(1) /循环display(); / 扫描数码管 任务五: LED 滚动闪烁控制#define uchar unsigned charuchar table15=0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe;uint count,i,num;void int_int()EX0=1;/ 允许外部中断EX1=1;void key1_1() interrupt 0num=num-2000;if(num<=2000)num=2000;void key2_2() interrupt 2void timer_0() interrupt 1 #include<reg52.h>#define uchar unsigned char#define uint unsigned int#define a2#define e2#define T 1000sbit key=P37;/ 880.000Hz a2/ 659.255Hz e2/定义音符结构/发声频率(对应的定时器初值)/发声时值uchar ReloadH;uchar ReloadL;TMOD=0x01;ET0=1; void sound(CNote *note) SPEAKER=1;void inter() interrupt 1#include<reg52.h>/ 头文件#define uint unsigned intTMOD=0x05;/ 设置计数器 0 工作方式 1ET0=1; / 打开计数器 0 中断TR0=1;/ 启动定时器 0void beep_interrupt() interrupt 1 / 计数器 0 中断服务子程序 #include<reg52.h>#define uint unsigned int#define uchar unsigned charuchar table15=0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe;uint count,i,num;void int_int()EX0=1;/ 允许外部中断EX1=1;void key1_1() interrupt 0void key2_2() interrupt 2 void timer_0() interrupt 1 12MHz , 单片机 P0,P2 端口作为输出口,外接#define uchar unsigned char TMOD=0X01; 单片机甲机的 P3.2 外接按键 K1,P3.3 外接按键;单片机乙机P0、P2 端口作为输出口,外始/暂停”控制按键,甲机的按键PC 发送过来的 09 的数字,并将接受的科教兴国43

注意事项

本文(单片机程序源代码[共43页])为本站会员(1528****253)主动上传,装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知装配图网(点击联系客服),我们立即给予删除!

温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!