AT89C51
基于AT89C51的编程
静安书以沫
知识是一点点积累的,路是一步步走出来的
展开
-
单片机中断系统编程,4
iic#include<iic.h>void delay10us(void) //10us{ unsigned char a,b; for(b=1;b>0;b--) for(a=2;a>0;a--);}void iicstart()//起始信号{ SDA=1; delay10us(); SCL=1; delay10us(); SDA=0; delay10us(); SCL=0; delay10us();}voi原创 2020-11-04 08:59:01 · 233 阅读 · 0 评论 -
单片机中断系统编程,3
定时器流水灯#include<reg51.h>#include<intrins.h>typedef unsigned char u8;typedef unsigned int u16;#define led P2 void delay(u16 i){ while(i--) { u16 j=120; while(j--); }}void yvchuli(){ TMOD=0x01;//选择定时器 TH0=0xFC;//赋给高8位初值 TL0=0X18;原创 2020-11-03 15:55:21 · 236 阅读 · 0 评论 -
单片机中断系统编程,2
定时器#include<reg51.h>#include<intrins.h>typedef unsigned char u8;typedef unsigned int u16;sbit led1=P2^4;sbit led2=P2^5;sbit led3=P2^6;sbit led4=P2^7;sbit key3=P3^2;sbit key4=P3^3;#define led P2 void delay(u16 i){ while(i--) { u1原创 2020-11-03 15:53:10 · 911 阅读 · 0 评论 -
单片机中断系统编码,1
串口,外部中断,定时器#include<reg51.h>#include<intrins.h>typedef unsigned char u8;typedef unsigned int u16;sbit led1=P2^0;sbit key=P3^2; u8 i,a,b,c; u8 x;void delay(u8 a){while(a--) {u8 j=180; while(j--);}}void yvchuli(){ TMOD|=0x01; TH原创 2020-11-03 15:50:20 · 978 阅读 · 0 评论 -
显示器显示1-9变换。显示函数。矩阵按后在左边显示-----数码管
显示器显示1-9变换#include<reg51.h>typedef unsigned char uchar;typedef unsigned int uint;uchar code led[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};void delay(uint i){ uint j; while(i--) { j=124; while(j--); }}void main(){ ucha原创 2020-11-03 15:45:09 · 321 阅读 · 0 评论 -
定时器时钟
定时器时钟#include<reg52.h>typedef unsigned char u8;typedef unsigned int u16;sbit k1=P3^1;u8 code duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};u8 code wei[8]={0xe3,0xe7,0xeb,0xef,0xf3,0xf7,0xfb,0xff}; u8原创 2020-11-03 15:43:08 · 370 阅读 · 0 评论 -
红外通信小车
红外通信小车红外通信遥控器按下按键后,会发射响应的高低电平变化的波,按响应的规律解码这些波,可以读出每个按键发射的波对应的数据,小车可以根据这些数据进行运动#include<reg51.h>typedef unsigned char u8;typedef unsigned int u16;sbit IN1=P1^0;sbit IN2=P1^1;sbit IN3=P1^2;sbit IN4=P1^3;sbit en1=P2^0;sbit en2=P2^1;sbit IRIN=原创 2020-11-02 19:48:55 · 184 阅读 · 0 评论 -
基于51的小车制作 pwm+蓝牙+lcd+ds1302+外部中断
基于51的小车制作 pwm+蓝牙+lcd+ds1302+外部中断#include<reg51.h>#include<intrins.h>/*按K3为蓝牙控制 01直行 01后退 03左转 04右转 05停止 06LCD计时开启 07计时停止 08计时清零 09调速按K4为寻迹模式按键时蜂鸣器发音提示*/typedef unsigned char u8;typedef unsigned int u16;#define lcd P0sbit IN1=P1^1;sb原创 2020-10-27 16:35:16 · 377 阅读 · 0 评论 -
DS1302时钟
DS1302时钟#include<reg51.h>#include<intrins.h>typedef unsigned char u8;typedef unsigned int u16;sbit ce=P3^5; sbit sclk=P3^6; sbit io=P3^4; #define lcd P0sbit rs=P2^6;sbit rw=P2^5;sbit e=P2^7;u8 code read[7]={0x81,0x83,0x85,0x87原创 2020-10-27 16:33:02 · 154 阅读 · 0 评论 -
蓝牙HC-05 --基于51
蓝牙HC-05 --基于51#include<reg51.h>#include<intrins.h>typedef unsigned char u8;typedef unsigned int u16;#define led P2 u8 receive; u8 x;void yvchuli(){ TMOD=0x20;//方式2,自动装载8位 TL1=0xf3; TH1=0xf3; PCON=0X80; TR1=1; SCON=0x50; ES=1;//打原创 2020-10-27 16:31:23 · 202 阅读 · 0 评论 -
超声波测距模块使用-基于51
超声波测距模块使用-基于51#include <reg51.h>typedef unsigned char u8;typedef unsigned int u16;u8 code ledseg[11]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x40}; u8 code ledloc[8]={0xe3,0xe7,0xeb,0xef,0xf3,0xf7,0xfb,0xff};u8 ledcach[8]={0x40原创 2020-10-27 16:29:47 · 218 阅读 · 0 评论 -
LCD电子时钟
LCD电子时钟#include<reg51.h>#include <intrins.h>typedef unsigned char u8;typedef unsigned int u16;sbit DS1302_CE=P3^5;sbit DS1302_SCLK=P3^6;sbit DS1302_IO=P3^4;u8 datetime[8];#define LCD_DB P0sbit LCD_RS=P2^6;sbit LCD_RW=P2^5;sbit LCD_E原创 2020-10-27 16:28:16 · 905 阅读 · 0 评论 -
数码管-按键加1且满10进1,初始显示00000000
数码管-按键加1且满10进1,初始显示00000000#include<reg52.h>typedef unsigned char u8;typedef unsigned int u16;sbit k1=P3^1;u8 code duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};u8 code wei[8]={0xe3,0xe7,0xeb,0xef,0xf3原创 2020-10-27 16:27:05 · 1257 阅读 · 0 评论 -
流水灯-奇偶变换
流水灯-奇偶变换#include<reg51.h>typedef unsigned char u8;typedef unsigned int u16;void delay(u16 i){ u16 j; while(i--) { for(j=0;j<120;j++); }}void main (){ u8 led; while(1) { P2=led; led=0x55; delay(200); P2=led; led=原创 2020-10-27 16:22:57 · 1493 阅读 · 0 评论 -
流水灯-移位函数
流水灯-移位函数#include<reg51.h>#include<intrins.h>typedef unsigned char uchar;typedef unsigned int uint;uint x,y;void delay(uint i){ while(i--) { uint j=0; for(j=0;j<124;j++); }}void main (){ uchar led; while(1) { led=0xfe; f原创 2020-10-27 16:21:06 · 1127 阅读 · 0 评论 -
流水灯-移位符
流水灯-移位符#include<reg51.h>#include<intrins.h>typedef unsigned char uchar;typedef unsigned int uint;uint x,y;void delay(uint i){ while(i--) { uint j=0; for(j=0;j<124;j++); }}void main (){ y=0x1; while(1) { for(x=0;x<原创 2020-10-27 16:20:02 · 233 阅读 · 0 评论 -
流水灯-数组
流水灯-数组#include<reg51.h>typedef unsigned char uchar;typedef unsigned int uint;uint code a[4]={0x7f,0xdf,0xf7,0xfd};uint code b[4]={0xbf,0xef,0xfb,0xfe};uint x,y;void delay(uint i){ while(i--) { uint j=0; for(j=0;j<124;j++); }}void原创 2020-10-27 16:18:54 · 1678 阅读 · 0 评论