单片机
lionwerson
二次元技术宅一名
展开
-
Arduino Esp8266 Web LED控制
arduino esp8266 web控制和LED控制:web.inoindex.htmlarduino.inoweb.html然后在arduino的项目目录下创建data文件夹,然后把index.html文件放入后,用esp8266fs工具写入到flash中,连接wifi之后就可以了。esp8266fs工具:Releases · esp8266/arduino-esp8266fs-plugin......原创 2022-06-24 11:35:20 · 1713 阅读 · 0 评论 -
MicroPython Server网页LED开关
最近入手了TPYBoard v202:下面用的是micropython开发的led例程,板子连接wifi后获取到Ip地址,并打印在串口上,通过ip地址用浏览器访问页面,实现控制led开关:效果:我在官方的例程做了稍稍改动,去除了登录页面,美化了一下控制页面:由于esp8266自带内存太小,一次性打开的device.html不可以太大,否则会出现网页文件不全,在手机端无法显示网页,所以一定要注意这个。device.htmlmain.pyserver.zippython还是适用于树莓派之类的性能高的比较合适原创 2022-06-24 11:28:39 · 299 阅读 · 0 评论 -
51单片机仿真例程-PWM直流电动机
通过单片机输出PWM波,控制占空比实现控制电动机的转速,方向,启停。代码:#include<reg51.h>#include<intrins.h> #define uint unsigned int#define uchar unsigned charsbit K1=P3^0;sbit K2=P3^1;sbit K3=P3^2;sbit K_up = P3^3;sbit K_down = P3^4;sbit LED1=P0^0;sbit LED2=P0原创 2021-10-05 10:12:23 · 679 阅读 · 2 评论 -
51单片机仿真例程-DA波形发生器
通过DAC0832实现数模转换输出锯齿波形。代码:#include<reg51.h>#include<absacc.h>#define uint unsigned int#define uchar unsigned char #define DAC0832 XBYTE[0xFFFe]void DelayMS(uint t){ uchar i; while(t--) { for(i=0;i<120;i++); }}void main(){原创 2021-10-05 10:12:49 · 777 阅读 · 0 评论 -
51单片机仿真例程-单总线温度计
代码:利用DS18B20温度传感器实现温度计#include<reg51.h>#include<stdio.h>#include<intrins.h>sbit DQ=P3^3;sbit RSPIN=P2^0;sbit RWPIN=P2^1;sbit EPIN=P2^2;sbit d=P1^0;unsigned char first[13]="current temp:";unsigned char time[9]={0,0,0,0,'.',0,原创 2021-10-05 10:13:34 · 373 阅读 · 0 评论 -
51单片机仿真例程-串行AD转换电压表
利用ADC模块TLC2543实现串行AD转换#include<reg51.h>#define uchar unsigned charsbit CS=P2^0;sbit CLK=P2^1;sbit DIN=P2^2;sbit DOUT=P2^3;sbit EOC=P2^4;sbit gwei=P3^3; uchar tabd[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};uchar tab[10]={0xc0原创 2021-10-05 10:14:06 · 538 阅读 · 0 评论 -
51单片机仿真例程-AD转换电压表
代码:#include<reg51.h>#define uchar unsigned charsbit cjclk=P2^4;sbit EOC=P3^2;sbit key=P2^5;uchar tab[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};uchar tabd[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};uchar xsjs;uc原创 2021-10-05 10:14:37 · 1056 阅读 · 0 评论 -
51单片机仿真例程-串行EEPROM扩展
代码:通过IIC总线写入24C04模块#include<reg51.h>#include<intrins.h>#define uchar unsigned char#define uint unsigned int#define AddWr24c04 0xa0#define AddRd24c04 0xa1#define delay4us(){_nop_();_nop_();_nop_();_nop_();_nop_();};sbit SDA=P1^1;sb原创 2021-10-05 10:14:59 · 355 阅读 · 0 评论 -
51单片机仿真例程-并行RAM扩展
代码:#include<reg51.h>#include<absacc.h>#define uchar unsigned char#define uint unsigned intsbit led = P1^0;int xdata time _at_ 0xca;void main(){ uint i; led = 1; for(i=0;i<200;i++) { XBYTE[i]=i+1; } for(i=0;i<200;i++原创 2021-10-05 10:15:20 · 591 阅读 · 1 评论 -
51单片机仿真例程-IO扩展
代码:#include<reg51.h>#include<intrins.h>#define uint unsigned int#define uchar unsigned char void delay(uint x){ uchar i; while(x--) { for(i=0;i<120;i++); }}void main(){ uchar c=0xe0; P1 = 0x80; while(1) { c原创 2021-10-05 10:15:43 · 333 阅读 · 0 评论 -
51单片机仿真例程-模拟交通灯
代码:#include<reg51.h>#define uchar unsigned charvoid delay0_5s(){ uchar i; for(i=0;i<0x0a;i++) { TH0=0x3c; TL0=0xb0; TR0=1; while(!TF0); TF0=0; }}void delay_t(uchar t){ uchar i; for(i=0;i<t;i++) delay0_5s();}void原创 2021-10-05 10:16:01 · 683 阅读 · 0 评论 -
51单片机仿真例程-双机通信
双机通信,一个甲为发送,一个乙作为接收。甲:#include<reg51.h>sbit k1=P0^0;sbit k2=P0^1;unsigned char fabuf[3];unsigned char sj1[3]={0xa0,0x1,0x2};unsigned char sj2[3]={0xa1,0x3,0x4};void init_UART(void){ SCON=0x50; PCON=0x0; TMOD=0x20; TH1=0xF4; TL1=TH1;原创 2021-10-05 10:11:45 · 1660 阅读 · 0 评论 -
51单片机仿真例程-双机串行通信
计算机与外界通信进行信息交换成为通信。通信的方式分为串行通信和并行通信。并行通信是指数据同时进行传送,串行通信是指数据一位一位地依次传输,两种通信方式各有优缺点。#include<reg51.h>#define uchar unsigned char;code uchar tab_cc[]={0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};sbit K0=P1^0;uchar dat[10]={0,1,2,3,4,5,6,7,原创 2021-10-05 00:30:00 · 8310 阅读 · 2 评论 -
51单片机仿真例程-万年历
驱动DS1302模块,显示时间#include<reg51.h>#include<intrins.h>#include<stdio.h>sbit RSPIN = P3^0;sbit RWPIN = P3^1;sbit EPIN = P3^2;sbit DS1302_CLK = P0^1;sbit DS1302_IO = P0^0;sbit DS1302_RST = P0^2;sbit ACC0 = ACC^0;sbit ACC7 = ACC^7原创 2021-10-05 00:30:00 · 545 阅读 · 0 评论 -
51单片机仿真例程-蜂鸣器
通过单片机定时器输出方波,不同的频率声调不同。#include<reg52.h>sbit beep = P1^5;unsigned char code music_h[]={0xfc,0xfc,0xfc,0xfd,0xfd,0xfd,0xfe};unsigned char code music_l[]={0x44,0xbe,0x0a,0x34,0x83,0xc8,0x06}; //adint i;void d原创 2021-10-05 00:45:00 · 1368 阅读 · 0 评论 -
51单片机仿真例程-按键扫描
按键扫描分为逐行扫描和线反转法扫描逐行扫描:#include<reg51.h>unsigned char disp[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};unsigned char scanh[4]={0xfe,0xfd,0xfb,0xf7};void delay1ms(unsigned char x){unsigned char i,j;for(;x>=1;x--) for(i=20;i&原创 2021-10-05 00:45:00 · 979 阅读 · 0 评论 -
51单片机仿真例程-八段数码管
八段数码管静止显示:#include <reg51.h>#define uchar unsigned charuchar code tab[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};void delay(int count){int i,j; for(i=0;i<count;i++) for(j=0;j<120;j++) ; } void main(void){while(1) .原创 2021-10-05 00:30:00 · 1330 阅读 · 0 评论 -
51单片机仿真例程-lCD显示
51单片机驱动LCD显示hello world#include<reg51.h>#include<stdio.h>#include<intrins.h>sbit RSPIN=P3^0;sbit RWPIN=P3^1;sbit EPIN=P3^2;unsigned char str1[]="HELLO WORLD!";void delay3ms(void){ unsigned char i,j,k; for(i=0;i<18;i++)原创 2021-10-05 00:15:00 · 772 阅读 · 0 评论 -
51单片机仿真例程-led点阵屏
用51单片机驱动led点阵屏 #include <reg51.h>unsigned char hang[10]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};unsigned char tab_lie[10][8]={{0xc3,0x99,0x99,0x99,0x99,0x99,0x99,0xc3}, {0xe7,0xc7,0xe7,0xe7,0xe7,0xe7,0xe7,0xc3},原创 2021-10-05 00:30:00 · 721 阅读 · 0 评论 -
51单片机仿真例程-开关控制
通过读取针脚电平高低来实现控制,51单片机的针脚没有stm32的状态多和复杂。代码:#include<reg51.h> #include<reg51.h>sbit x=P3^7;sbit y=P3^6;main(){ while(1){ x=1; y=1; if(x==0) P1=0xf0; if(y==0) P1=0xaa; if(x==1&&y==1) P1=0xff;}}效果图:.原创 2021-10-05 00:15:00 · 1613 阅读 · 0 评论 -
51单片机仿真例程-流水灯
单片机经典流水灯效果,通过端口循坏移位实现代码:#include<reg51.h>#include<intrins.h>void delay(unsigned int a){ unsigned int i; while( --a!=0) { for(i=0;i<125;i++); }}/*void main(void){ while(1) { P1=0xff; delay(200); P1=0x00; de原创 2021-10-05 00:00:00 · 1200 阅读 · 0 评论 -
51单片机仿真例程-led点灯
一.51单片机虽然已经过时了,不如主流的stm32类的单片机,但是仍是学习单片机最简单的入门的单片机,这是一个入门单片机最重要的点灯例程。代码:#include <reg52.h>sbit led1=P1^0;sbit led2=P1^1;void delay(unsigned int n){ unsigned char i; while(--n) for(i=0;i<125;i++);}int main(void){ while(1) {原创 2021-10-05 01:00:00 · 643 阅读 · 0 评论