中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

網(wǎng)站頁面類型/正規(guī)網(wǎng)站優(yōu)化哪個(gè)公司好

網(wǎng)站頁面類型,正規(guī)網(wǎng)站優(yōu)化哪個(gè)公司好,作文網(wǎng)站源碼,北京市網(wǎng)站設(shè)計(jì)-推廣公司iic.c /* # I2C代碼片段說明1. 本文件夾中提供的驅(qū)動(dòng)代碼供參賽選手完成程序設(shè)計(jì)參考。2. 參賽選手可以自行編寫相關(guān)代碼或以該代碼為基礎(chǔ)&#xff0c;根據(jù)所選單片機(jī)類型、運(yùn)行速度和試題中對(duì)單片機(jī)時(shí)鐘頻率的要求&#xff0c;進(jìn)行代碼調(diào)試和修改。 */ #include <STC1…

?

?

?

?

iic.c

/*	#   I2C代碼片段說明1. 	本文件夾中提供的驅(qū)動(dòng)代碼供參賽選手完成程序設(shè)計(jì)參考。2. 	參賽選手可以自行編寫相關(guān)代碼或以該代碼為基礎(chǔ),根據(jù)所選單片機(jī)類型、運(yùn)行速度和試題中對(duì)單片機(jī)時(shí)鐘頻率的要求,進(jìn)行代碼調(diào)試和修改。
*/
#include <STC15F2K60S2.H>
#include "iic.h"
#include "intrins.h"sbit scl = P2^0;
sbit sda = P2^1;#define DELAY_TIME	5//
static void I2C_Delay(unsigned char n)
{do{_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();		}while(n--);      	
}//
void I2CStart(void)
{sda = 1;scl = 1;I2C_Delay(DELAY_TIME);sda = 0;I2C_Delay(DELAY_TIME);scl = 0;    
}//
void I2CStop(void)
{sda = 0;scl = 1;I2C_Delay(DELAY_TIME);sda = 1;I2C_Delay(DELAY_TIME);
}//
void I2CSendByte(unsigned char byt)
{unsigned char i;for(i=0; i<8; i++){scl = 0;I2C_Delay(DELAY_TIME);if(byt & 0x80){sda = 1;}else{sda = 0;}I2C_Delay(DELAY_TIME);scl = 1;byt <<= 1;I2C_Delay(DELAY_TIME);}scl = 0;  
}//
unsigned char I2CReceiveByte(void)
{unsigned char da;unsigned char i;for(i=0;i<8;i++){   scl = 1;I2C_Delay(DELAY_TIME);da <<= 1;if(sda) da |= 0x01;scl = 0;I2C_Delay(DELAY_TIME);}return da;    
}//
unsigned char I2CWaitAck(void)
{unsigned char ackbit;scl = 1;I2C_Delay(DELAY_TIME);ackbit = sda; scl = 0;I2C_Delay(DELAY_TIME);return ackbit;
}//
void I2CSendAck(unsigned char ackbit)
{scl = 0;sda = ackbit; I2C_Delay(DELAY_TIME);scl = 1;I2C_Delay(DELAY_TIME);scl = 0; sda = 1;I2C_Delay(DELAY_TIME);
}unsigned int Read_v()
{unsigned int temp;I2CStart();I2CSendByte(0x90);I2CWaitAck();I2CSendByte(0x01);I2CWaitAck();I2CStart();I2CSendByte(0x91);I2CWaitAck();temp = I2CReceiveByte();I2CSendAck(1);I2CStop();return temp;
}

?iic.h

#ifndef __iic_h
#define __iic_hstatic void I2C_Delay(unsigned char n);
void I2CStart(void);
void I2CStop(void);
void I2CSendByte(unsigned char byt);
unsigned char I2CReceiveByte(void);
unsigned char I2CWaitAck(void);
void I2CSendAck(unsigned char ackbit);
unsigned int Read_v();#endif

onewire.c

/*	# 	單總線代碼片段說明1. 	本文件夾中提供的驅(qū)動(dòng)代碼供參賽選手完成程序設(shè)計(jì)參考。2. 	參賽選手可以自行編寫相關(guān)代碼或以該代碼為基礎(chǔ),根據(jù)所選單片機(jī)類型、運(yùn)行速度和試題中對(duì)單片機(jī)時(shí)鐘頻率的要求,進(jìn)行代碼調(diào)試和修改。
*///
#include <STC15F2K60S2.H>
#include "onewire.h"sbit DQ = P1^4;void Delay_OneWire(unsigned int t)  
{unsigned char i;while(t--){for(i=0;i<12;i++);}
}//
void Write_DS18B20(unsigned char dat)
{unsigned char i;for(i=0;i<8;i++){DQ = 0;DQ = dat&0x01;Delay_OneWire(5);DQ = 1;dat >>= 1;}Delay_OneWire(5);
}//
unsigned char Read_DS18B20(void)
{unsigned char i;unsigned char dat;for(i=0;i<8;i++){DQ = 0;dat >>= 1;DQ = 1;if(DQ){dat |= 0x80;}	    Delay_OneWire(5);}return dat;
}//
bit init_ds18b20(void)
{bit initflag = 0;DQ = 1;Delay_OneWire(12);DQ = 0;Delay_OneWire(80);DQ = 1;Delay_OneWire(10); initflag = DQ;     Delay_OneWire(5);return initflag;
}unsigned int Read_temp()
{unsigned char LSB ,MSB;init_ds18b20();Write_DS18B20(0xcc);Write_DS18B20(0x44);init_ds18b20();Write_DS18B20(0xcc);Write_DS18B20(0xbe);LSB = Read_DS18B20();MSB = Read_DS18B20();return (MSB << 8 | LSB ) * 0.625;
}

onewire.h

#ifndef __onewire_h
#define __onewire_hvoid Delay_OneWire(unsigned int t);
void Write_DS18B20(unsigned char dat);
unsigned char Read_DS18B20(void);
bit init_ds18b20(void);
unsigned int Read_temp();#endif

ds1302.c

/*	# 	DS1302代碼片段說明1. 	本文件夾中提供的驅(qū)動(dòng)代碼供參賽選手完成程序設(shè)計(jì)參考。2. 	參賽選手可以自行編寫相關(guān)代碼或以該代碼為基礎(chǔ),根據(jù)所選單片機(jī)類型、運(yùn)行速度和試題中對(duì)單片機(jī)時(shí)鐘頻率的要求,進(jìn)行代碼調(diào)試和修改。
*/								//
#include <STC15F2K60S2.H>
#include "ds1302.h"
#include "intrins.h"sbit SCK = P1^7;
sbit SDA = P2^3;
sbit RST = P1^3;code unsigned char Write_addr[] = {0x80,0x82,0x84,0x86,0x88,0x8a,0x8c};
code unsigned char Read_addr[] = {0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
unsigned char time[] = {0x50,0x59,0x16};
void Write_Ds1302(unsigned  char temp) 
{unsigned char i;for (i=0;i<8;i++)     	{ SCK = 0;SDA = temp&0x01;temp>>=1; SCK=1;}
}   //
void Write_Ds1302_Byte( unsigned char address,unsigned char dat )     
{RST=0;	_nop_();SCK=0;	_nop_();RST=1; 	_nop_();  Write_Ds1302(address);	Write_Ds1302(dat);		RST=0; 
}//
unsigned char Read_Ds1302_Byte ( unsigned char address )
{unsigned char i,temp=0x00;RST=0;	_nop_();SCK=0;	_nop_();RST=1;	_nop_();Write_Ds1302(address);for (i=0;i<8;i++) 	{		SCK=0;temp>>=1;	if(SDA)temp|=0x80;	SCK=1;} RST=0;	_nop_();SCK=0;	_nop_();SCK=1;	_nop_();SDA=0;	_nop_();SDA=1;	_nop_();return (temp);			
}void Write_time()
{char i;Write_Ds1302_Byte(0x8e,0x00);for(i = 0;i < 3;i++)Write_Ds1302_Byte(Write_addr[i],time[i]);Write_Ds1302_Byte(0x8e,0x80);
}void Read_time()
{char i;for(i = 0;i < 3;i++)time[i] = Read_Ds1302_Byte(Read_addr[i]);
}

ds1302.h

#ifndef __ds1302_h
#define __ds1302_hvoid Write_Ds1302(unsigned  char temp) ;
void Write_Ds1302_Byte( unsigned char address,unsigned char dat ) ;
unsigned char Read_Ds1302_Byte ( unsigned char address );
void Write_time();
void Read_time();#endif

sys.c

#include <STC15F2K60S2.H>
#include "sys.h"
#include "intrins.h"
void Delay_ms(unsigned int t)		//@12.000MHz
{while(t--){unsigned char i, j;i = 12;j = 169;do{while (--j);} while (--i);}
}void Select_Hc573(char n)
{switch(n){case 4:P2 = P2 & 0x1f | 0x80;break;case 5:P2 = P2 & 0x1f | 0xa0;break;case 6:P2 = P2 & 0x1f | 0xc0;break;case 7:P2 = P2 & 0x1f | 0xe0;break;}P2 = P2 & 0x1f;
}void Sys_Init()
{P0 = 0x00;Select_Hc573(5);P0 = 0xff;Select_Hc573(4);
}void Select_Bit(unsigned char pos,dat)
{P0 = 0x01 << pos;Select_Hc573(6);P0 = dat;Select_Hc573(7);Delay_ms(1);P0 = 0xff;Select_Hc573(7);
}

sys.h

#ifndef __sys_h
#define __sys_hvoid Delay_ms(unsigned int t);
void Select_Hc573(char n);
void Sys_Init();
void Select_Bit(unsigned char pos,dat);#endif

main.c

#include <STC15F2K60S2.H>
#include "ds1302.h"
#include "iic.h"
#include "onewire.h"
#include "sys.h"sbit R1 = P3^0;
sbit R2 = P3^1;
sbit R3 = P3^2;
sbit R4 = P3^3;
sbit C1 = P4^4;
sbit C2 = P4^2;
sbit C3 = P3^5;
sbit C4 = P3^4;code unsigned char SMG[] = { ~0x3F,~0x06,~0x5B,~0x4F,~0x66,~0x6D,~0x7D,~0x07,~0x7F,~0x6F,~0x71,~0x76};
extern unsigned char time[];
unsigned int temp;//溫度
unsigned int v;//電壓
bit v_stata;//	1-亮	0-暗
bit flag_500ms;
bit flag_10ms;
unsigned char count1;
unsigned int count2,count3;
char param_time = 17;//時(shí)間參數(shù)
char param_temp = 25;//溫度參數(shù)
char param_led = 4;//led參數(shù)
unsigned char key_val;//鍵值
bit mode;//0-數(shù)據(jù)界面	1-參數(shù)界面
unsigned char mode_dat;//0-時(shí)間	1-溫度	2-亮暗狀態(tài)
unsigned char mode_param;//0-時(shí)間	1-溫度	2-LED
bit L3_flag;//	0-滅	1-亮void Display_time()//時(shí)間界面
{Select_Bit(0,SMG[time[2] / 16]);Select_Bit(1,SMG[time[2] % 16]);Select_Bit(2,SMG[0]);Select_Bit(3,SMG[time[1] / 16]);Select_Bit(4,SMG[time[1] % 16]);Select_Bit(5,SMG[0]);Select_Bit(6,SMG[time[0] / 16]);Select_Bit(7,SMG[time[0] % 16]);
}void Display_temp()//溫度界面
{Select_Bit(0,SMG[10]);Select_Bit(5,SMG[temp / 100]);Select_Bit(6,SMG[temp / 10 % 10] - 0x80);Select_Bit(7,SMG[temp % 10]);
}void Display_v()//亮暗狀態(tài)顯示
{Select_Bit(0,SMG[11]);Select_Bit(2,SMG[v / 100] - 0x80);Select_Bit(3,SMG[v / 10 % 10]);Select_Bit(4,SMG[v % 10]);Select_Bit(7,SMG[v_stata]);
}void Display_param_time()//時(shí)間參數(shù)界面
{Select_Bit(0,SMG[5]);Select_Bit(1,SMG[4]);Select_Bit(6,SMG[param_time / 10]);Select_Bit(7,SMG[param_time % 10]);
}void Display_param_temp()//溫度參數(shù)界面
{Select_Bit(0,SMG[5]);Select_Bit(1,SMG[5]);Select_Bit(6,SMG[param_temp / 10]);Select_Bit(7,SMG[param_temp % 10]);
}void Display_param_led()//指示燈參數(shù)界面
{Select_Bit(0,SMG[5]);Select_Bit(1,SMG[6]);Select_Bit(7,SMG[param_led]);
}void Timer2Init(void)		//10毫秒@12.000MHz
{AUXR &= 0xFB;		//定時(shí)器時(shí)鐘12T模式T2L = 0xF0;		//設(shè)置定時(shí)初值T2H = 0xD8;		//設(shè)置定時(shí)初值A(chǔ)UXR |= 0x10;		//定時(shí)器2開始計(jì)時(shí)IE2 = 1 << 2;EA = 1;
}void Timer2_isr() interrupt 12
{if(++count1 > 50){count1 = 0;flag_500ms = 1;//光敏電阻半秒刷新}flag_10ms = 1;//按鍵掃描刷新if(!v_stata)//L3判斷{if(++count2 > 300){count2 = 0;L3_flag = 1;}count3 = 0;}else{count2 = 0;if(++count3 > 300){count3 = 0;L3_flag = 0;}}
}unsigned char Key_Scan()//按鍵掃描函數(shù)
{unsigned char temp = 0;static unsigned char cnt4 = 0;static unsigned char cnt5 = 0;static unsigned char cnt8 = 0;static unsigned char cnt9 = 0;if(flag_10ms){R3 = 0;R1 = R2 = R4 = C1 = C2 = C3 = C4 = 1;if(C1 == 0)	cnt5++;if(C1 == 1){if(cnt5 > 2)	temp = 5;cnt5 = 0;}if(C2 == 0)	cnt9++;if(C2 == 1){if(cnt9 > 2)	temp = 9;cnt9 = 0;}R4 = 0;R1 = R2 = R3 = C1 = C2 = C3 = C4 = 1;if(C1 == 0)	cnt4++;if(C1 == 1){if(cnt4 > 2)	temp = 4;cnt4 = 0;}if(C2 == 0)	cnt8++;if(C2 == 1){if(cnt8 > 2)	temp = 8;cnt8 = 0;}flag_10ms = 0;}return temp;
}void Key_Pro()
{switch(key_val){case 4:mode ^= 1;if(!mode)	mode_param = 0;else	mode_dat = 0;break;case 5:if(!mode){if(++mode_dat > 2)mode_dat = 0;}else{if(++mode_param > 2)mode_param = 0;}break;case 8:if(mode){switch(mode_param){case 0:if(--param_time < 0)param_time = 23;break;case 1:if(--param_temp < 0)param_temp = 99;break;case 2:if(--param_led < 4)param_led = 8;break;}}break;case 9:if(mode){switch(mode_param){case 0:if(++param_time > 23)param_time = 0;break;case 1:if(++param_temp > 99)param_temp = 0;break;case 2:if(++param_led > 8)param_led = 4;break;}}break;}
}void Led(unsigned char addr,enable)//LED底層代碼
{static unsigned char temp = 0x00;static unsigned char temp_old = 0xff;if(enable)	temp |= 0x01 << addr;else	temp &= ~(0x01 << addr);if(temp != temp_old){P0 = ~temp;Select_Hc573(4);temp_old = temp;}
}void Led_Pro()//LED控制代碼
{if(param_time <= time[2] / 16 * 10 + time[2] % 16)	Led(0,1);else	Led(0,0);if(((float)temp) / 10 < param_temp)	Led(1,1);else	Led(1,0);if(L3_flag)	Led(2,1);else	Led(2,0);if(!v_stata){switch(param_led){case 4:Led(3,1);Led(4,0);Led(5,0);Led(6,0);Led(7,0);break;case 5:Led(4,1);Led(3,0);Led(5,0);Led(6,0);Led(7,0);break;case 6:Led(5,1);Led(4,0);Led(3,0);Led(6,0);Led(7,0);break;case 7:Led(6,1);Led(4,0);Led(5,0);Led(3,0);Led(7,0);break;case 8:Led(7,1);Led(4,0);Led(5,0);Led(6,0);Led(3,0);break;}}else{Led(3,0);Led(4,0);Led(5,0);Led(6,0);Led(7,0);}
}void main()
{Sys_Init();//系統(tǒng)初始化關(guān)閉繼電器和蜂鳴器Read_temp();//讀取溫度延時(shí)750ms以消除上電顯示85Delay_ms(750);Write_time();//初始化寫入時(shí)間Timer2Init();//定時(shí)器2初始化while(1){temp = Read_temp();//讀取溫度Read_time();//讀取時(shí)間if(flag_500ms)//半秒讀取一次光敏電阻電壓{flag_500ms = 0;v = Read_v() / 51.0 * 100;}if(v > 150)	v_stata = 1;else	v_stata = 0;key_val = Key_Scan();//讀取鍵值Key_Pro();//按鍵處理函數(shù)Led_Pro();//LED處理函數(shù)if(!mode)//0-數(shù)據(jù)界面	1-參數(shù)界面{switch(mode_dat)//0-時(shí)間界面	1-溫度界面	2-亮暗狀態(tài)界面{case 0:Display_time();break;case 1:Display_temp();break;case 2:Display_v();break;}}else//參數(shù)界面下{switch(mode_param)//0-時(shí)間參數(shù)界面	1-溫度參數(shù)界面	2-LED參數(shù)界面{case 0:Display_param_time();break;case 1:Display_param_temp();break;case 2:Display_param_led();break;}}}
}

http://www.risenshineclean.com/news/730.html

相關(guān)文章:

  • 推廣網(wǎng)站最有效方法/自己有貨源怎么找客戶
  • 重慶網(wǎng)站建設(shè)設(shè)計(jì)/怎么去推廣一個(gè)app
  • 網(wǎng)站微營銷公司哪家好/鄭州疫情最新動(dòng)態(tài)
  • 品牌logo設(shè)計(jì)說明/百度seo優(yōu)化公司
  • 有什么做任務(wù)得傭金的網(wǎng)站/站長之家app
  • 做淘寶有哪些推廣網(wǎng)站/seo外鏈友情鏈接
  • 開發(fā)公司取名字大全免費(fèi)查詢/貴陽網(wǎng)站優(yōu)化公司
  • 代碼判斷網(wǎng)站/上海百度競價(jià)托管
  • 運(yùn)動(dòng)網(wǎng)站建設(shè)教程/上海網(wǎng)站排名優(yōu)化公司
  • 濟(jì)南做網(wǎng)站xywlcn/百度用戶服務(wù)中心官網(wǎng)
  • 南海區(qū)住房和城鄉(xiāng)建設(shè)部網(wǎng)站/提高網(wǎng)站排名軟件
  • 河南那家公司做家具行業(yè)網(wǎng)站好/電商培訓(xùn)有用嗎
  • 中山品牌網(wǎng)站建設(shè)推廣/軟件培訓(xùn)機(jī)構(gòu)有哪些?哪個(gè)比較好
  • 東莞工信部網(wǎng)站/公司排名seo
  • java做網(wǎng)站pdf/網(wǎng)絡(luò)營銷成功案例ppt
  • 學(xué)生怎樣做網(wǎng)站/模板建站哪里有
  • 免費(fèi)網(wǎng)站制作公司/長春網(wǎng)站關(guān)鍵詞推廣
  • 網(wǎng)站產(chǎn)品頁面/注冊(cè)安全工程師
  • 鄭州做網(wǎng)站 碼通/長沙做網(wǎng)站的公司有哪些
  • 紀(jì)檢監(jiān)察信訪舉報(bào)網(wǎng)站建設(shè)/如何創(chuàng)建一個(gè)網(wǎng)頁
  • 鉆井網(wǎng)站建設(shè)/seo外包公司多少錢
  • 網(wǎng)站建設(shè)策略/湘潭網(wǎng)頁設(shè)計(jì)
  • 網(wǎng)站建設(shè)需要數(shù)據(jù)庫嗎/成都百度提升優(yōu)化
  • 個(gè)人網(wǎng)站做短視頻/seo網(wǎng)站推廣助理招聘
  • 建設(shè)網(wǎng)站要多長時(shí)間/app推廣方法及技巧
  • 網(wǎng)站建設(shè)哪個(gè)公司好知乎/東莞關(guān)鍵詞優(yōu)化實(shí)力樂云seo
  • 不用登錄的小游戲網(wǎng)站/推廣平臺(tái)怎么找客源
  • 香港做網(wǎng)站公司哪家好/平臺(tái)推廣策劃方案
  • 云南網(wǎng)站優(yōu)化公司/商丘seo排名
  • wordpress手機(jī)編輯器/博客可以做seo嗎