标签:use nbsp ima clu load mic sig image oid
点亮LED实验:
#include <reg52.h> sbit LED1 = P1^0; sbit LED2 = P1^1; sbit LED8 = P1^7; void main() { LED1 = 0; LED2 = 0; LED8 = 0; while(1); }
流水:
#include <reg52.h> #include <intrins.h> #define uchar unsigned char #define uint unsigned int //How to use the header file intrins.h //_crol_ 字符循环左移 //_cror_ 字符循环右移 //_nop_ 空操作8051 NOP 指令
//LED = _crol_(LED,1)执行一次后的结果为0x1111 1101
sbit LED1 = P1^0; uchar i; uchar temp; void delay(uint z) { uint x,y; for(x = z; x > 0; x--) for(y = 120; y > 0 ; y--); } void main() { temp = 0x7f;// 0111 1111 P1 = temp; while(1) { for(i = 0; i < 8; i++) { temp = _cror_(temp,1);//循环右移 P1 = temp; delay(1000); } } }
数码管静态显示:
数码管外部结构:
数码管内部结构:
#include <reg52.h> #include <intrins.h> #define uchar unsigned char #define uint unsigned int sbit we = P2^7; sbit du = P2^6; uchar code leddata[]={ 0x3F, //"0" 0x06, //"1" 0x5B, //"2" 0x4F, //"3" 0x66, //"4" 0x6D, //"5" 0x7D, //"6" 0x07, //"7" 0x7F, //"8" 0x6F, //"9" 0x77, //"A" 0x7C, //"B" 0x39, //"C" 0x5E, //"D" 0x79, //"E" 0x71, //"F" 0x76, //"H" 0x38, //"L" 0x37, //"n" 0x3E, //"u" 0x73, //"P" 0x5C, //"o" 0x40, //"-" 0x00, //熄灭 0x00 //自定义 }; void delay(uint z) { uint x,y; for(x = z; x > 0; x--) for(y = 114; y > 0 ; y--); } void main() { du = 1; //打开段选 P0 = leddata[10]; du = 0; //关闭段选 //delay(5); we = 1;//打开位选 P0 = 0; we = 0; //关闭位选 while(1); }
标签:use nbsp ima clu load mic sig image oid
原文地址:https://www.cnblogs.com/darren-pty/p/13282972.html