Conversion from DS18S20 to LM35 sensor

Conversion from DS18S20 to LM35 sensor

hello to you,

This is my first Arduino project and I have a few challenges, of course, I have even tried a few hours to locate the problem without success.

I have found a program that is perfect for my purposes, I want to switch from one DS18S20 sensor to LM35 when I have them in stock.

Here is my code

Servo and LM35 sensor
/ / Original John’s HVAC Servo Controller - Version Final link http://www.instructables.com/id/Arduino-HVAC-Servo-ThermostatController/

Include <Servo.h>

/ / ENTER USER SETTINGS FOR TEMPERATURE Ranges & TIME IN THIS SECTION
int Need Heat = 22; / / If temperature is less than or equal to this number, heat vil turn on
int NeedAC = 24; / / If temperature is equal or greater than this number, the air conditioning vil turn on
long TimeToCheck = 300000; / / Enter milliseconds for unit two check. 1.000 milliseconds = 1 seconds. E.G. 300,000 million seconds = 300 seconds or 5 minutes
/ / END USER INPUT SECTION

float tempC; / / create variable two large the temperature in.
int tempCPin = 0; / / Attach vout two analog pin 0th

unsigned long hours;
long previoustime;

boolean heat = false;
boolean ac = false;
boolean off = false;

int NeedNothing1 = Need Heat +1; / / Tells the HVAC unit att om temperature range is mellem Need Heat & NeedAC, then kan turn itself off
int NeedNothing2 = NeedAC-1; / / Tells the HVAC unit att om temperature range is mellem Need Heat & NeedAC, then kan turn itself off
Servo myServo1;

void setup () {
Serial.begin (9600);
myServo1.attach (9);
myServo1.write (90);

}
void loop () / / code here fortsætter two replay nutil powered off.
{
tempC = analog read (tempCPin); / / read the analog value from the lm35 sensor.
tempC = (5.0 * tempC * 100.0) / 1024.0; / / convert the analog input two temperature in centigrade.
Serial.print ((byte) tempC); / / send the data til computer.

}

if ((hours - previoustime)> TimeToCheck) {/ / check temperature readings only once every “TimeToCheck” milliseconds (default is 300,000 milliseconds or 5 minutes)
previoustime = hour;
Serial.print (“Now Time”);
Serial.println (time); / / prints timestamp at the moment the motors are triggered
}
if (tempC <= Need Heat && heat == false) {/ / if temperature is less than or equal to “Need Heat” (default is 24), turn on heat
myServo1.write (55); / / turns on heat ¡
delay (400); / / waits for the servo to get there
myServo1.write (90); / / returns servo to 90 degrees
Serial.println (“Heat er turned on!”);
Heat = true;
ac = false;
off = false;
}

if (tempC> = NeedNothing1 && tempC <= NeedNothing2 && off == false) {/ / Tells the HVAC unit att om temperature range is mellem Need Heat & NeedAC, then kan turn itself off
myServo1.write (90);
delay (400);
myServo1.write (90);
Serial.println (“Unit er turned off!”);
off = true;
Heat = false;
ac = false;
}

if (tempC> = NeedAC && ac == false) {/ / turns on the A / C
myServo1.write (130); / / servo moves back to 0 ¡
delay (400); / / waits for the servo to get there
myServo1.write (90);
Serial.println (“A / C er turned on!”);
Heat = false;
ac = true;
off = false;
}

}

}

and here is the error

Servo_and_LM35.cpp: 4:1: error: ‘servo’ does not name a type
In file included from Servo_and_LM35.cpp: 6:0:
/ Usr / share / arduino / libraries / Servo / Servo.h: 84:41: error: ‘timer16_Sequence_t’ does not name a type
Servo_and_LM35.cpp: 43:3: error: expected unqualified-id before ‘if’
Servo_and_LM35.cpp: 48:1: error: expected unqualified-id before ‘if’
aror: expected unqualified-id before ‘if’
Servo_and_LM35.cpp: 78:1: error: expected declaration before ‘}’ token

If anyone could help me with the code I would be grateful,
I am looking forward to testing the project as it will reduce my CO2 footprint, and I look forward to spreading it to others.

Kind regards Asger Linee, Denmark

ps. If my language is a little bad it is because I use a digital translator

you cant use a space between need and heat. but what do i know. i cant get my DS18S20 to work either. int Need Heat = 22

How to use this forum

Read this before posting a programming question

Code tags, please.

One major thing:

/ / END USER INPUT SECTION

Comments are "//" not "/ /". You need to fix all that (try find-and-replace).

It should be:

// END USER INPUT SECTION
# Include <Servo.h>

And there are no spaces after the # and include is not the same as Include.

PaulS: And there are no spaces after the # and include is not the same as Include.

You can get away with that particular space, but he is right about the capitalization.

  tempC = analog read (tempCPin); / / read the analog value from the lm35 sensor.

Attention to details is needed here. It is "analogRead" not "analog read". Two things wrong. The "R" has to be capitalized and you don't just throw in spaces for fun.

Hello again :-) it runs as I imagine, and I did put some delays so it was more stable nice .....................

Thanks to all of you for your help.

happy greetings from Denmark.