
아두이노를 이용하여 화재경보시스템을 만들려고 하는데요. 일단 적정 온도가 올라가면 부저가 울리게 코드를 작성해 보았습니다!
float sinVal;
int toneVal;
unsigned long tepTimer ;
void setup(){
pinMode(8, OUTPUT);
Serial.begin(9600);
}
void loop(){
int val;
double data;
val=analogRead(0);
data = (double) val * (5/10.24); // convert the voltage to temperture
if(data>27){ // If the temperture is over 27 degree, buzzer will alarm.
for(int x=0; x<180; x++){
sinVal = (sin(x*(3.1412/180)));
toneVal = 2000+(int(sinVal*1000));
tone(8, toneVal);
delay(2);
}
} else { // If the temperturn is below 27 degree, buzzer will not alarm
noTone(8);
}
if(millis() - tepTimer > 500){ // output the temperture value per 500ms
tepTimer = millis();
Serial.print("temperature: ");
Serial.print(data);
Serial.println("C");
}
}
그리고 부저가 아닌 블루투스 모듈을 사용해 휴대폰으로 연결하여 온도가 올라가면 부저가 아닌 휴대폰에 경보음이 나게 하고 싶은데요

뉴아트라는 블루투스를 사용할려고 합니다~이 부품을 사용할려면 어떻게 코드를 작성하면 좋을지 조언 부탁드립니다ㅠㅠ
아니면 더 좋은 부품이 있다면 추천 부탁드려요!!
|