单片机C语言程序设计实训100例--基于8051-PROTEUS仿真1.doc

上传人:龙*** 文档编号:90567 上传时间:2018-07-05 格式:DOC 页数:77 大小:1.87MB
下载 相关 举报
单片机C语言程序设计实训100例--基于8051-PROTEUS仿真1.doc_第1页
第1页 / 共77页
单片机C语言程序设计实训100例--基于8051-PROTEUS仿真1.doc_第2页
第2页 / 共77页
单片机C语言程序设计实训100例--基于8051-PROTEUS仿真1.doc_第3页
第3页 / 共77页
单片机C语言程序设计实训100例--基于8051-PROTEUS仿真1.doc_第4页
第4页 / 共77页
单片机C语言程序设计实训100例--基于8051-PROTEUS仿真1.doc_第5页
第5页 / 共77页
点击查看更多>>
资源描述

1、单片机 C语言程序设计实训 100例 -基于 8051和 PROTEUS仿真案例 1 上海师范大学信息与机电工程学院 倪继锋 单片机 C语言程序设计实训 100例 基于 8051+Proteus 仿真案例 第 01 篇 基础 程序设计 01 闪烁的 LED /* 名称:闪烁的 LED 说明: LED 按设定的时间间隔闪烁 */ #include #define uchar unsigned char #define uint unsigned int sbit LED=P10; /延时 void DelayMS(uint x) uchar i; while(x-) for(i=0;i #inc

2、lude #define uchar unsigned char #define uint unsigned int 单片机 C语言程序设计实训 100例 -基于 8051和 PROTEUS仿真案例 2 上海师范大学信息与机电工程学院 倪继锋 /延时 void DelayMS(uint x) uchar i; while(x-) for(i=0;i #include #define uchar unsigned char #define uint unsigned int /延时 void DelayMS(uint x) uchar i; while(x-) for(i=0;i #define

3、 uchar unsigned char #define uint unsigned int uchar code Pattern_P0= 0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff, 0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1

4、f,0x3f,0x7f, 0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff, 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe, 0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00

5、,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe, 0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff ; uchar code Pattern_P2= 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf9,0xf3,0xe7,0xcf,0x9f,0x3f,0xff, 0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0

6、xff,0xe7,0xc3,0x81,0x00,0x81,0xc3,0xe7,0xff, 0xaa,0x55,0x18,0xff,0xf0,0x0f,0x00,0xff,0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f, 0x7f,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xff,0x00,0x00,0xff,0xff,0x0f,0xf0,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f, 0x7f,0xbf,0x

7、df,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00, 0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 单片机 C语言程序设计实训 100例 -基于 8051和 PROTEUS仿真案例 4 上海师范大学信息与机电工程学院 倪继锋 0x00,0

8、xff,0x00,0xff,0x00,0xff,0x00,0xff ; /延时 void DelayMS(uint x) uchar i; while(x-) for(i=0;i #define uchar unsigned char #define uint unsigned int sbit RED_A=P00; /东西向灯 sbit YELLOW_A=P01; sbit GREEN_A=P02; sbit RED_B=P03; /南北向灯 sbit YELLOW_B=P04; sbit GREEN_B=P05; uchar Flash_Count=0,Operation_Type=1;

9、/闪烁次数,操作类型变量 单片机 C语言程序设计实训 100例 -基于 8051和 PROTEUS仿真案例 5 上海师范大学信息与机电工程学院 倪继锋 /延时 void DelayMS(uint x) uchar i; while(x-) for(i=0;i #include #define uchar unsigned char #define uint unsigned int uchar code DSY_CODE=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff; /延时 void DelayMS(uint x) uchar

10、t; while(x-) for(t=0;t #include #define uchar unsigned char #define uint unsigned int uchar code DSY_CODE=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90; /延时 void DelayMS(uint x) 单片机 C语言程序设计实训 100例 -基于 8051和 PROTEUS仿真案例 7 上海师范大学信息与机电工程学院 倪继锋 uchar t; while(x-) for(t=0;t #include #define uchar uns

11、igned char #define uint unsigned int uchar code DSY_CODE=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90; /延时 void DelayMS(uint x) uchar t; while(x-) for(t=0;t #define uchar unsigned char #define uint unsigned int /段码表 uchar code DSY_CODE=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90; /位码表 uch

12、ar code DSY_IDX=0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80; /延时 void DelayMS(uint x) uchar t; while(x-) for(t=0;t #include #define uchar unsigned char #define uint unsigned int /段码表 uchar code DSY_CODE=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff; /下面数组看作环形队列,显示从某个数开始的 8 个数( 10 表示黑屏) uchar Nu

13、m=10,10,10,10,10,10,10,10,2,9,8; /延时 void DelayMS(uint x) uchar t; while(x-) for(t=0;t #include #define uchar unsigned char #define uint unsigned int /延时 void DelayMS(uint x) uchar i; while(x-) for(i=0;i120;i+); /根据 P1 口的按键移动LED void Move_LED() if (P1 /K1 else if(P1 /K2 else if(P1 /K3 else if(P1 /K4 /主程序 void main() uchar Recent_Key; /最近按键 P0=0xfe; P2=0xfe; P1=0xff; Recent_Key=0xff; while(1) if(Recent_Key!=P1) Recent_Key=P1; /保存最近按键 Move_LED(); DelayMS(10);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育教学资料库 > 课件讲义

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。