功能
读取dht11,显示到lcd1602显示屏,串口发送到电脑。
部分程序
void main(void)
{char disp[20];char count = 0;WDTCTL = WDTPW + WDTHOLD; // Stop WDTP1DIR = 0Xff;P1SEL = 0X00;P1SEL2 = 0X00;P2DIR = 0Xff;P2SEL = 0X00;P2SEL2 = 0X00;LCD_init();LCD_clear_home();while (1){/* 如果读取到了 并且校验成功 */if (receive_init() == 1){/* 存入数组 */count = 0;disp[count++] = ' ';disp[count++] = humdh % 100 / 10 + '0';disp[count++] = humdh % 10 / 1 + '0';disp[count++] = '%';disp[count++] = 'R';disp[count++] = 'H';disp[count++] = ' ';disp[count++] = temph % 100 / 10 + '0';disp[count++] = temph % 10 / 1 + '0';disp[count++] = 'C';disp[count++] = 0;LCD_goto(0, 0);LCD_putstr(disp);Print_Str(disp);Print_Str(" ----\r\n");}delay_ms(500);}
}
全部代码
https://docs.qq.com/sheet/DUEdqZ2lmbmR6UVdU?tab=BB08J2