ho provato a scrivere ma sicuramente mi manca qualcosa ma non so dove sbaglio
Analog input, analog output, serial output
Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 9 to ground
created 29 Dec. 2008
by Tom Igoe
*/
#include <EEPROM.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// These constants won't change. They're used to give names
// to the pins used:
float tempC;
int TempC_Decimal = 0;
int tempPin = 0;
int DigitalPin = 13;
int TemperaturaMinima = 22;
int value = 0;
int isteresi = 1;
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
lcd.begin(4,20);
value = EEPROM.read(0);
if (value == 1)
{
TemperaturaMinima = EEPROM.read(1);
}
pinMode isteresi, INPUT) ;
}
void loop() {
if (Serial.available() > 0)
{
// read the incoming byte:
TemperaturaMinima = Serial.read();
EEPROM.write(0, 1);
EEPROM.write(1, TemperaturaMinima);
buttonState =digitalRead(isteresi);
if(buttonState == HIGH)
{ isteresi += 0.1}
}
tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
TempC_Decimal = (tempC - (tempC)) * 100;
lcd.clear();
lcd.print ( "TEMP.INTERNA +" );
lcd.setCursor (14,0);
lcd.print(tempC); //send the data to the computer
lcd.setCursor (19,0);
lcd.print(TempC_Decimal); //send the data to the computer
lcd.setCursor (2,2);
Serial.println(TemperaturaMinima);
lcd.setCursor (0,1);
lcd.print ( "TEMP.di soglia +" );
lcd.setCursor (18,1); //sposta i gradi di soglia sull'lcd
lcd.print(TemperaturaMinima); // scrive temperatura di soglia
if (tempC < TemperaturaMinima)
if (tempC (TemperaturaMinima + isteresi))
{
digitalWrite(DigitalPin, HIGH); // set the LED on
delay(4000); // wait for a second
}
if (tempC > (TemperaturaMinima + 1))
{
digitalWrite(DigitalPin, LOW); // set the LED on
delay(4000);
}
delay(200);
}
questo e con il casino
e questo funziona ma non imposta il livello di intervento ventola
/*
Analog input, analog output, serial output
Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.
The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 9 to ground
created 29 Dec. 2008
by Tom Igoe
*/
#include <EEPROM.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// These constants won't change. They're used to give names
// to the pins used:
float tempC;
int TempC_Decimal = 0;
int tempPin = 0;
int DigitalPin = 13;
int TemperaturaMinima = 22;
int value = 0;
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
lcd.begin(4,20);
value = EEPROM.read(0);
if (value == 1)
{
TemperaturaMinima = EEPROM.read(1);
}
}
void loop() {
if (Serial.available() > 0)
{
// read the incoming byte:
TemperaturaMinima = Serial.read();
EEPROM.write(0, 1);
EEPROM.write(1, TemperaturaMinima);
}
tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
TempC_Decimal = (tempC - (tempC)) * 100;
lcd.clear();
lcd.print ( "Temp.Interna +" );
lcd.setCursor (14,0);
lcd.print(tempC); //send the data to the computer
lcd.setCursor (19,0);
lcd.print(TempC_Decimal); //send the data to the computer
lcd.setCursor (2,2);
Serial.println(TemperaturaMinima);
lcd.setCursor (0,1);
lcd.print ( "Temp.Attivazione +" );
lcd.setCursor (18,1); //sposta i gradi di soglia sull'lcd
lcd.print(TemperaturaMinima); // scrive temperatura di soglia
lcd.setCursor (0,2);
lcd.print ( "Umidita' Int. %" );
if (tempC < TemperaturaMinima)
{
digitalWrite(DigitalPin, HIGH); // set the LED on
delay(4000); // wait for a second
}
if (tempC > (TemperaturaMinima + 1))
{
digitalWrite(DigitalPin, LOW); // set the LED on
delay(4000);
}
delay(200);
}