用一个压力传感器和蓝牙同时控制一个小灯,单片机蓝牙程序应该写在哪,
- #include <reg52.h>
- #include <stdio.h>
- #include “lcd1602.h”
- //ADC0809
- sbit CLK=P3^4;
- sbit ST=P3^5;
- sbit EOC=P3^6;
- sbit OE=P3^7;
- sbit RELAY = P3^3;
- unsigned int ADCval;
- unsigned char pressure = 50;
- unsigned char mode=0;
- unsigned char status = 0;
- void delay(unsigned long s)
- {
- while(s–);
- }
- void DelayMS(unsigned int ms)
- {
- unsigned char i;
- while(ms–)
- {
- for(i=0;i<120;i++);
- }
- }
- void Timer0_INT() interrupt 1
- {
- TH0=(65536-200)/256;
- TL0=(65536-200)%256;
- CLK=~CLK;
- }
- void main(void)
- {
- RELAY=1;
- lcd_init();
- TMOD=0x01;
- TH0=(65536-200)/256;
- TL0=(65536-200)%256;
- EA=1;
- ET0=1;
- TR0=1;
- while(1)
- {
- ST=0;
- OE=0;
- ST=1;
- ST=0;
- while(EOC==0);
- OE=1;
- ADCval=P1;
- OE=0;
- LCD_ShowStr(0,0,”Real:”);
- LCD_ShowChar(5,0,ADCval/100+’0′);
- LCD_ShowChar(6,0,ADCval%100/10 +’0′);
- LCD_ShowChar(7,0,ADCval%10 +’0′);
- if(ADCval<=pressure){
- RELAY=0;
- }
- else {
- RELAY=1;
- }
- }
- }
复制代码
,电路图
,单片机和蓝牙之间用UART口交换数据,单片机是主控,采集压力传感器和蓝牙收到的数据,单片机根据预设的协议控制灯,程序烧写在单片机中。,
munuc_w 发表于 2021-1-14 10:02
单片机和蓝牙之间用UART口交换数据,单片机是主控,采集压力传感器和蓝牙收到的数据,单片机根据预设的协议 …
蓝牙程序写在一个中断里面吗