- 博客(13)
- 收藏
- 关注
原创 矩阵键盘的识别==》密码锁
用扫描法,一行一行的检测按键是否被按下: 键盘扫描函数: #include <REGX52.H> #include "Delay.h" unsigned char MatrixKey() { unsigned char KeyNumber=0; P1=0xFF; P1_3=0; if(P1_7==0){Delay(20);while(P1_7==0);Delay(20);KeyNumber=1;} if(P1_6==0){Delay(20);while(P1_6==0);Del
2022-06-01 10:45:00
272
原创 LCD1602调试工具
LCD作为显示屏是单片机工作返回数据最直观的体现。 下面将以模块化编程的思想调用LCD进行显示。 如下代码就是LCD的模块,显示时调用即可; #include <REGX52.H> sbit LCD_RS=P2^6; sbit LCD_RW=P2^5; sbit LCD_EN=P2^7; #define LCD_DataPort P0 void LCD_Delay() { unsigned char i, j; i = 2; j = 239; do { while (
2022-05-31 14:44:26
635
原创 模块化编程
在实际工程问题中一个项目是可以分成很多个模块,让不同的人去负责一个模块,从而高效率的完成这个工程。各个模块之间独立存在,如果下次还需要某一个模块,也可以很方便的移植。 延迟模块 #include <INTRINS.H> void Delay(unsigned int xms) { unsigned char i, j; while(xms--) { _nop_(); i = 2; j = 199; do { while (--j); } while (
2022-05-29 19:57:47
244
原创 动态数码管显示
#include <REGX52.H> #include <INTRINS.H> unsigned char wztable[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; void Delay1ms(unsigned int xms) { unsigned char i, j; while(xms--) { _nop_(); i = 2; ...
2022-01-08 18:00:00
381
原创 静态数码管显示
#include <REGX52.H> unsigned char wztable[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; void weizhi(unsigned char Location,Number) { switch(Location) { case 1:P2_4=1;P2_3=1;P2_2=1;break; case 2:P2_4=1;P2_3=1;P2_2=0;b...
2022-01-08 06:00:00
300
原创 独立按键控制LED移位
#include <REGX52.H> #include <INTRINS.H> void Delay1ms(unsigned int xms) { unsigned char i, j; while(xms--) { _nop_(); i = 2; j = 199; do { while (--j); } while (--i);...
2022-01-07 18:00:00
268
原创 独立按键控制LED显示二进制
#include <REGX52.H> #include <INTRINS.H> void Delay1ms(unsigned int xms) { unsigned char i, j; while(xms--) { _nop_(); i = 2; j = 199; do { while (--j); } while (--i);...
2022-01-07 06:00:00
334
原创 独立按键控制LED状态
#include <REGX52.H> #include <INTRINS.H> void Delay1ms(unsigned int xms) { unsigned char i, j; while(xms) { _nop_(); i = 2; j = 199; do { while (--j); } while (--i...
2022-01-06 18:00:00
101
原创 独立按键控制LED亮灭
#include <REGX52.H> void main() { while(1) { if(P3_1==0) { P2_0=0; } else { P2_0=1; ...
2022-01-06 06:30:00
457
原创 LED流水灯Plus
#include <REGX52.H> #include <INTRINS.H> void Delay1ms(unsigned int xms) //@11.0592MHz { unsigned char i, j; while(xms) { _nop_(); i = 2; j = 199; do { while (--j); } ...
2022-01-05 18:00:00
247
原创 LED流水灯
#include <REGX52.H> #include <INTRINS.H> void Delay100ms() //@11.0592MHz { unsigned char i, j; i = 180; j = 73; do { while (--j); } while (--i); } void main() { while(1) { P2=0xFE;//111...
2022-01-05 06:30:00
109
原创 LED闪烁
#include <REGX52.H> #include <INTRINS.H> void Delay100ms() //@11.0592MHz { unsigned char i, j; i = 180; j = 73; do { while (--j); } while (--i); } void main() { while(1) { P2=0...
2022-01-04 12:43:48
253
原创 点亮一个LED
#include <REGX52.H> void main() { P2=0xFE;//1111 1110 while(1) { } }
2022-01-02 14:08:11
453
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅