本人用的是MSP430F149系列单片机,不过这个程序是MSP430F2系列的单片机,能不能帮我看看程序怎么修改才可以运用才MSP430F149中,谢谢了,可以加QQ聊,这个是DHT11温湿度传感器
#include <msp430x22x4.h> #include "dht11.h" #include "usart.h" const char word1[] = {"\r\n**DHT11 TEST**\r\n"}; const char word2[] = {"\r\n**DHT11 CHECK**\r\n"}; const char word3[] = {"\r\n**DHT11 NOT EXIST**\r\n"}; void display(void); int main( void ) { WDTCTL=WDTPW+WDTHOLD; //关看门狗 Usart_Init(); P1DIR |=BIT0;//点亮LED0 RED P1OUT &=~BIT0; P1DIR |=BIT1;//点亮LED1 GREEN TXString((char*)word1, sizeof word1); delay_ms(1000); delay_ms(1000); while(1) { if(start_DHT11()) //如果应答成功 { P1OUT |=BIT0; TXString((char*)word2, sizeof word2); read_DHT11(); //读温湿度 display(); //则显示温湿度数值 } else { P1OUT &=~BIT0; TXString((char*)word3, sizeof word3); } P1OUT |=BIT1; delay_ms(1000); P1OUT &=~BIT1; delay_ms(1000); } } void display(void) { unsigned char table[11]; table[0]=humidity/0x10+0x30;//湿度 table[1]=humidity/0x10+0x30; table[2]='%'; table[3]='R'; table[4]='H'; table[5]=' '; table[6]=temperature/0X10+0x30;//温度 table[7]=temperature%0X10+0x30; table[8]='C'; table[9]='\r'; table[10]='\n'; TXString((char*)table, sizeof table); }
|