freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

畢業(yè)設(shè)計-基于單片機的智能溫室溫濕度控制系統(tǒng)的設(shè)計-資料下載頁

2024-12-03 18:50本頁面

【導(dǎo)讀】在溫室大棚中,最關(guān)鍵的是溫濕度控制方法。傳統(tǒng)的溫濕度控制方。法完全是人工的,不僅費時費力,而且效率低。無線通信模塊nRF2401、液晶顯示LCD1602等組成。通過無線傳感器nRF2401來進行信號傳送,這樣能夠降低布線的麻。AT89S52,接收傳感器所測的數(shù)據(jù)并處理,然后執(zhí)行各種操作。高,可靠性高,系統(tǒng)工作穩(wěn)定,且綜合性價比較高,具有較大的市場應(yīng)用前景。關(guān)鍵詞:單片機,溫濕度控制系統(tǒng),溫濕度傳感器DHT11,LCD顯示,

  

【正文】 _us(unsigned char n); void StartUART( void ); void init_NRF24L01(void); uint SPI_RW(uint uchar); uchar SPI_Read(uchar reg); void SetRX_Mode(void); uint SPI_RW_Reg(uchar reg, uchar value); uint SPI_Read_Buf(uchar reg, uchar *pBuf, uchar uchars); uint SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars); 第 37 頁 共 74 頁 unsigned char nRF24L01_RxPacket(unsigned char* rx_buf); void nRF24L01_TxPacket(unsigned char * tx_buf); void read_TRH(); char receive(); //**********************長延時 *************************** void Delay(unsigned int s) { unsigned int i; for(i=0; is; i++); for(i=0; is; i++); } void delay_ms(unsigned char ms) { unsigned char i; while(ms) { for(i = 0。 i 150。 i++) { _nop_(); _nop_(); _nop_(); _nop_(); } } } /*********************************************************/ /*********************************************************/ //5us 級延時程序 /*********************************************************/ void delay_us() { unsigned char i; i; i; i; i; i; i; 第 38 頁 共 74 頁 } //******************************************************** uint bdata sta; //狀態(tài)標(biāo)志 sbit RX_DR=sta^6; sbit TX_DS=sta^5; sbit MAX_RT=sta^4; /********************************************************** /*延時函數(shù) /**********************************************************/ void inerDelay_us(unsigned char n) { for(; n0; n) _nop_(); } //********************************************************** /*NRF24L01 初始化 //**********************************************************/ void init_NRF24L01(void) { inerDelay_us(100); CE=0; // chip enable CSN=1; // Spi disable SCK=0; // Spi clock line init high SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH); // 寫本地地址 SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, RX_ADDRESS, RX_ADR_WIDTH); // 寫接收端地址 第 39 頁 共 74 頁 SPI_RW_Reg(WRITE_REG + EN_AA, 0x01); // 頻道 0 自動 ACK 應(yīng)答允許 SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01); // 允許接收地址 只有頻道 0,如果需要多頻道可以參考 Page21 SPI_RW_Reg(WRITE_REG + RF_CH, 0); // 設(shè)置信道工作為 ,收發(fā)必須一致 SPI_RW_Reg(WRITE_REG + RX_PW_P0, RX_PLOAD_WIDTH); //設(shè)置接收數(shù)據(jù)長度,本次設(shè)置為 32 字節(jié) SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07); //設(shè)置發(fā)射速率為1MHZ,發(fā)射功率為最大值 0dB SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); // IRQ 收發(fā)完成中斷響應(yīng), 16位 CRC,主發(fā)送 } /******************************************************** /*函數(shù): uint SPI_RW(uint uchar) /*功能: NRF24L01 的 SPI 寫時序 /********************************************************/ uint SPI_RW(uint uchar) { uint bit_ctr; for(bit_ctr=0。bit_ctr8。bit_ctr++) // output 8bit { MOSI = (uchar amp。 0x80); // output 39。uchar39。, MSB to MOSI uchar = (uchar 1); // shift next bit into MSB.. SCK = 1; // Set SCK high.. 第 40 頁 共 74 頁 uchar |= MISO; // capture current MISO bit SCK = 0; // ..then set SCK low again } return(uchar); // return read uchar } /********************************/*函數(shù): uchar SPI_Read(uchar reg) /*功能: NRF24L01 的 SPI 時序 /********************************************************/ uchar SPI_Read(uchar reg) { uchar reg_val; CSN = 0; // CSN low, initialize SPI munication... SPI_RW(reg); // Select register to read from.. reg_val = SPI_RW(0); // ..then read registervalue CSN = 1; // CSN high, terminate SPI munication return(reg_val); // return register value } /*********************************************************/ /*功能: NRF24L01 讀寫寄存器函數(shù) /*********************************************************/ uint SPI_RW_Reg(uchar reg, uchar value) { uint status; CSN = 0; // CSN low, init SPI transaction status = SPI_RW(reg); // select register 第 41 頁 共 74 頁 SPI_RW(value); // ..and write value to it.. CSN = 1; // CSN high again return(status); // return nRF24L01 status uchar } /**********************************************************/ /*函數(shù): uint SPI_Read_Buf(uchar reg, uchar *pBuf, uchar uchars) /*功能 : 用于讀數(shù)據(jù), reg:為寄存器地址, pBuf:為待讀出數(shù)據(jù)地址, uchars:讀出數(shù)據(jù)的個數(shù) /************************************************************/ uint SPI_Read_Buf(uchar reg, uchar *pBuf, uchar uchars) { uint status,uchar_ctr; CSN = 0; // Set CSN low, init SPI tranaction status = SPI_RW(reg); // Select register to write to and read status uchar for(uchar_ctr=0。uchar_ctruchars。uchar_ctr++) pBuf[uchar_ctr] = SPI_RW(0); // CSN = 1; return(status); // return nRF24L01 status uchar } /***************************************************/* 函數(shù): uint SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars) /*功能 : 用于寫數(shù)據(jù):為寄存器地址, pBuf:為待寫入數(shù)據(jù)地址, uchars:寫入數(shù)據(jù)的個數(shù) /**********************************************************/ 第 42 頁 共 74 頁 uint SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars) { uint status,uchar_ctr; CSN = 0; //SPI 使能 status = SPI_RW(reg); for(uchar_ctr=0。 uchar_ctruchars。 uchar_ctr++) // SPI_RW(*pBuf++); CSN = 1; //關(guān)閉 SPI return(status); // } /*********************************************************** /*函數(shù): void nRF24L01_TxPacket(unsigned char * tx_buf) /*功能:發(fā)送 tx_buf 中數(shù)據(jù) /************************************************/ void nRF24L01_TxPacket(unsigned char * tx_buf) { CE=0; //StandBy I 模式 SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // 裝載接收端地址 SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); // 裝載數(shù)據(jù) // SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); // IRQ 收發(fā)完成中斷響應(yīng), 16位 CRC,主發(fā)送 CE=1; //置高 C
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1