Hey,
this is my first Arduino project. everything is working fine but now i want to change the speed of the fan in the program (e.g. between 27°C and 30°C only 50% of the full speed and above that 100%). with a potentiometer i could do it but i want to have it completely automated. and yeah i know the program isn´t the best
first i´ll give you the code and you will finde a picture of the whole circuit. if you need any additional infos let me know.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int inputValue = 7;
int analogPin = A0;
int readValue = A0;
float temperature = A0;
int light=1;
int fan=6;
void setup(){
lcd.begin (16,2);
pinMode (light, INPUT);
pinMode (fan, OUTPUT);
Serial.begin(9600);
}
void loop(){
readValue = analogRead(analogPin);
temperature = (readValue * 0.0049);
temperature = temperature * 100;
int Lux=analogRead(light);
int clearLCD();// zeile nötig ?
Serial.println(temperature);
delay(1000);
Serial.println(Lux);
delay(1000);
if (Lux > 511){
lcd.setCursor(0, 0);
lcd.print("Bright");
}
else{
lcd.setCursor(0, 0);
lcd.print("Dark ");
}
if (temperature > 27){
digitalWrite(fan, HIGH );
lcd.setCursor(0, 1);
lcd.print(temperature);
lcd.print("C Fan: ON ");
}
else{
digitalWrite(fan, LOW);
lcd.setCursor(0, 1);
lcd.print(temperature);
lcd.print("C Fan: OFF");
}
}
thakns
Janis