# 목적
- 온도가 설정한 값 이상 올라가면 부저에서 경고를 낸다.
# 준비물
- 온도센서(LM35 Temperature) 1개, 부저(buzzer) 1개, 점퍼케이블 7개, 아두이노 보드, 브레드보드
# 입출력 설명
- 입력 : 온도 값(아날로그 값)
- 처리 : 온도의 양을 읽어(analogRead), 부저의 출력 값으로 쓰기(tone)
- 출력 : 부저의 소리(아날로그 값)
# 회로도
# 코드
## 아두이노 (arduino)
// code start
int inputPin = A2;
int outputPin = 8;
void setup() {
Serial.begin(9600);
}
void loop() {
int inputVal = analogRead(inputPin);
float voltage = (inputVal / 1024.0) * 5000.0;
float tempVal = (voltage - 500) / 10;
if (tempVal >= 25) {
tone(outputPin,392,100);
delay(100);
}
Serial.print(inputVal);
Serial.print(" ");
Serial.print(voltage);
Serial.print(" ");
Serial.println(tempVal);
delay(100);
}
// code end
## 코드아이플러스 (codeiPlus)
# 참고자료
온도센서 사용하기 : http://kocoafab.cc/tutorial/view/58