![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
stm51
L_nan.
普通小孩,热爱生活
展开
-
51单片机--蜂鸣器
#include "reg52.h"typedef unsigned char u8;typedef unsigned int u16;sbit BEEP=P2^5;void delay_10us(u16 ten_us) //当传入Ten_us=1时,大约延时10us{ while(ten_us--);}void main(){ u16 i=2000; //i值越大(也就是循环次数越多),蜂鸣器响的时间越久,不然可能声音滴一下就没了 while(1) { while.原创 2022-03-13 16:10:19 · 7779 阅读 · 1 评论 -
51单片机--实现跑马灯的两种办法
1.通过左移实现跑马灯#include "reg52.h"#define LED_PORT P0 //使用宏定义的方式将P0端口定义typedef unsigned char u8;typedef unsigned int u16;void delay_10us(u16 ten_us) //当传入Ten_us=1时,大约延时10us{ while(ten_us--);}void main(){ u8 i=0; while(1) { for(i=0;i<8;i原创 2022-03-11 20:19:58 · 10818 阅读 · 1 评论 -
51单片机LED灯闪烁
#include "reg52.h"//此处是为了方便之后定义变量(u8和u16分别代替前面的一串)typedef unsigned char u8; //一个字节 (无单位的浮点型)(0-127)typedef unsigned short int u16; //两个字节16位,所以命名为u16(无单位的整数型)(0-6535)sbit LED1=P0^0;//延时函数void delay_10us(u16 ten_us) //当传入Ten_us=1时,大约延时10us{ whil.原创 2022-03-10 11:48:21 · 1508 阅读 · 1 评论