Hello,
my na me is Niko and i am from Greece.
I am an electronic engineer around automations.
Since some years ago there were simple ways of
achieving automated projects with no programming at all.
Using cmos ic's you could do almost everything.
Now more complicated projects are coming up.
So the need of microprossesors is vital.
I am not such of programming because i never learned.
I have made a project which controls climate condition
on a travel Bus only by searching and reading around this forum.
It has an LM35 which reads temperature and a pot which controls
set temperature.
As you may understand in this sketch there are many parts which
have to be on or off and with many delays because of high currents
switching all these outputs.
everything works fine except the delay of writing on lcd the set temp
when i turn the knob, and is from all delays.
I started reading about millis() but honestly i did not figure it out
how to replace all these delays.
If there is any suggestion please tell me...
Thanks in advance
Niko
p.s. sorry for my long writing
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int tempPin = 5;
int potPin = A0;
int lowTemp = 10;
int highTemp = 34;
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("IONIAN TRANSPORT");
lcd.setCursor(0, 1);
lcd.print(" ZAZ-1101 ");
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
delay(5000);
}
void loop() {
int tempReading = analogRead(tempPin);
float tempVolts = (tempReading * 500) / 1024.0;
float temp = tempVolts;
int potValue = analogRead(potPin);
potValue = map(potValue, 0, 1023, lowTemp, highTemp);
lcd.clear();
lcd.print("Set: Temp:");
lcd.setCursor(5, 0);
lcd.print(potValue);
lcd.setCursor(14, 0);
lcd.print(tempVolts, 0);
//lcd.setCursor(0, 0);
digitalWrite(8, HIGH);
if (temp > potValue + 3) {
digitalWrite(A1, LOW);
digitalWrite(6, LOW);
delay(500);
digitalWrite(9, HIGH);
delay(500);
digitalWrite(10, HIGH);
} else {
delay(500);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(A2, LOW);
delay(500);
}
if (temp > potValue + 5) {
delay(500);
digitalWrite(A2, HIGH);
}
else {
digitalWrite(A2, LOW);
}
if (temp < potValue - 3) {
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(A2, LOW);
delay(1500);
digitalWrite(A1, HIGH);
delay(500);
digitalWrite(6, HIGH);
}
else {
delay(500);
digitalWrite(A1, LOW);
digitalWrite(6, LOW);
}
if (temp < potValue - 5) {
digitalWrite(7, HIGH);
}
else {
digitalWrite(7, LOW);
}
}
there was an extra delay after digitalWrite(8, HIGH); it was wrong
i deleted.