LM35 oldukça hassas sıcak ölçümü yapan bir sensör.
Burada elimizdeki ledler aracılığı ile her sıcaklık değişimini ledlerin yanması ile göstereceğiz.
Bu çalışmada 7 adet led kullandık. 20 derecenin altı için bir adet led 20 den 25 e kadar birer led ve 25 üstü için de 1 adet led kullandık.
//Arduino programımız aşağıdaki gibidir.
//Programızı for döngüsü ve case kullanarak sadeleştirebilirsiniz.
int pin1 = 7; //Led 1
int pin2 = 8; //Led 2
int pin3 = 9; //Led 3
int pin4 = 10; //Led 4
int pin5 = 11; //Led 5
int pin6 = 12; //Led 6
int pin7 = 13; //Led 7
int sensor1Pin = A0; //lm35 sensor
float temp =0;
int sensorValue = 0;
void setup() //setup
{
Serial.begin(9600);
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
}
void loop(){ //loop
{
float temp = analogRead(sensor1Pin); //check the temperature1
temp= (5.0 * temp * 100.0) / 1024;
Serial.print("sensor1:"); Serial.println(temp);
delay(500);
if(temp >= 30){
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 30 && temp >= 25 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 25 && temp >= 24 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 24 && temp >= 23 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 23 && temp >= 22 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 22 && temp >= 21 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 21 && temp >= 20 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 20 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
delay(500);
}
}
}
Burada elimizdeki ledler aracılığı ile her sıcaklık değişimini ledlerin yanması ile göstereceğiz.
Bu çalışmada 7 adet led kullandık. 20 derecenin altı için bir adet led 20 den 25 e kadar birer led ve 25 üstü için de 1 adet led kullandık.
//Arduino programımız aşağıdaki gibidir.
//Programızı for döngüsü ve case kullanarak sadeleştirebilirsiniz.
int pin1 = 7; //Led 1
int pin2 = 8; //Led 2
int pin3 = 9; //Led 3
int pin4 = 10; //Led 4
int pin5 = 11; //Led 5
int pin6 = 12; //Led 6
int pin7 = 13; //Led 7
int sensor1Pin = A0; //lm35 sensor
float temp =0;
int sensorValue = 0;
void setup() //setup
{
Serial.begin(9600);
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
}
void loop(){ //loop
{
float temp = analogRead(sensor1Pin); //check the temperature1
temp= (5.0 * temp * 100.0) / 1024;
Serial.print("sensor1:"); Serial.println(temp);
delay(500);
if(temp >= 30){
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 30 && temp >= 25 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, LOW);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 25 && temp >= 24 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, LOW);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 24 && temp >= 23 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, LOW);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 23 && temp >= 22 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, LOW);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 22 && temp >= 21 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, LOW);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 21 && temp >= 20 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, LOW);
delay(500);
}
if(temp < 20 ){
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(pin3, HIGH);
digitalWrite(pin4, HIGH);
digitalWrite(pin5, HIGH);
digitalWrite(pin6, HIGH);
digitalWrite(pin7, HIGH);
delay(500);
}
}
}
Hiç yorum yok:
Yorum Gönder