MQ2烟雾传感器+有源蜂鸣器模块


实现烟雾报警功能
主函数Mainpro.c
#include <stdio.h>
#include <string.h>
#include "controlDevice.h"
#include <unistd.h>
struct Device *findDeviceByName(char *name,struct Device *phead)
{
struct Device* tmp = phead;
if(phead == NULL){
return NULL;
}else{
while(tmp != NULL){
if(strcmp(tmp->DeviceName,name) == 0){
return tmp;
}
tmp = tmp->next;
}
return NULL;
}
}
int main()
{
if(wiringPiSetup() == -1){
printf("set up error!\n");
return -1;
}
struct Device *tmp = NULL;
struct Device *tmp1 = NULL;
char *name = "restaurant";
int frieStatus;
struct Device *pDeviceHead = NULL;
pDeviceHead = addrBathroomLight(pDeviceHead);
pDev