Activity 2 - Temperature Warning System
Materials Needed:
- Arduino Board
- Breadboard
- USB Cable
- Laptop
- Temperature Sensor
- Buzzer
- 1 x 330Ω
- 1 x LED
- 9 x Jumper Wires
int analogVal;
const int tempPin = A0;
float
voltage;
float
temperature;
const int led
= ?;
const int
buzzer = 6;
void
setup()
{
pinMode(tempPin, INPUT);
pinMode(led,?);
pinMode(buzzer,?);
Serial.begin(9600);
}
void loop()
{
analogVal=analogRead(tempPin);
voltage = (analogVal/1024.0)*5.0;
temperature = 100*voltage-50;
Serial.println(temperature);
delay(200);
if (temperature>30.0)
{
digitalWrite
(led,?);
digitalWrite
(buzzer,?);
delay (100);
}
else
digitalWrite(led,LOW);
digitalWrite(buzzer,LOW);
delay (100);
}
No comments:
Post a Comment