Попробовал собрать одну схему из двух:
1) Фоторезистор
2) Термодатчик
Получилось вот так...
Код вот такой:
int sensorPin = 0;
int tempc = 0;
int photocellPin = 2; // select the input pin for the photocell
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup()
{
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(38400);
}
void loop()
{
tempc = (5.0 * analogRead(sensorPin) * 100.0) / 1024.0;
Serial.println(tempc);
delay(1000);
val = analogRead(photocellPin); // read the value from the sensor
Serial.println(val);
if(val<=600){
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
delay(1000);
}
Вывод в монитор:
23 Celcius;
668 Light;
35 Celcius;
275 Light;
23 Celcius;
475 Light;
17 Celcius;
651 Light;
31 Celcius;
657 Light;
25 Celcius;
647 Light;
Т.е. термодатчик врет...
1) Фоторезистор
2) Термодатчик
Получилось вот так...
Код вот такой:
int sensorPin = 0;
int tempc = 0;
int photocellPin = 2; // select the input pin for the photocell
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup()
{
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(38400);
}
void loop()
{
tempc = (5.0 * analogRead(sensorPin) * 100.0) / 1024.0;
Serial.println(tempc);
delay(1000);
val = analogRead(photocellPin); // read the value from the sensor
Serial.println(val);
if(val<=600){
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
delay(1000);
}
Вывод в монитор:
23 Celcius;
668 Light;
35 Celcius;
275 Light;
23 Celcius;
475 Light;
17 Celcius;
651 Light;
31 Celcius;
657 Light;
25 Celcius;
647 Light;
Т.е. термодатчик врет...
у меня такая же фигня при подклюдчении кроме lm35 еще одного датчика. в чем прикол непонятно :(
ОтветитьУдалитьВам еще интересно узнать почему так?
ОтветитьУдалитьнужно использовать экранированный провод, и керамические конденсаторы по 0,1...1мкф между общим и сигналом. Например два конденсатора 105 (1 мкФ) с обоих концов провода.
Много времени прошло, и я отказался от термодатчиков, когда есть DS18B20 цифровой термометр
Удалить