Sample program
//////////////////////////////////////////////////////////
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
}
void loop() {
int vol = analogRead(A0) * (5.0 / 1023.0*100);
if (vol<=31)
{
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
}
else if (vol>=32 && vol<=40)
{
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
digitalWrite(11, LOW);
}
else if (vol>=41)
{
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
}
}
//////////////////////////////////////////////////////////
Result
Corresponding LED will be turned on in accordance with corresponding temperature range.
*******************************************************************************
keyestudio
// read temperature value of LM35
// low temperature area and LED setup
// low temperature area and LED setup
www.keyestudio.cc
73
Need help?
Do you have a question about the ARDUINO maker learning kit and is the answer not in the manual?