First Project bugs

Hi Guys,
I have just done my first project ever, it's a temperature sensor displayed on lcd screen. It's working good but after the temp is displayed there are 2 blocks showing on the lcd screen after the temp the second square has the middle pixle missing can anyone tell me why they are there and how to get rid of them?
Thanks Chris

Hi Chris.

post your code (use the # button above to make it look nice.) then we have a better chance to figure out whats wrong.

Are you by any chance using a serial LCD, and doing Serial.println() to display text? The ln on the end of the name means that the function appends a carriage return and line feed onto the end of the text. These are non-printing characters that the LCD is sure not to like.

Another question.
I want to set a digital output to high when a preset temp is reached (user settable using 2 bcd 0-9 rotary switches).
i will attach what i have already.

And the question is?

Hi Paul,
I have done alot of work since posting my program and will attach the new version. My question is: How do i introduce user settable alarm points ( to turn on led ) when certain temp reached ?
Thanks
Chris

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int ledPin = 13; // Select pin for LED
int sensorPin = A1; // Selects Analog input 2 as sensor
int sensorValue = 0; // Variable to store value from sensor

void setup() {

lcd.begin(16, 2); // Sets the number of rows & columns on LCD
pinMode(ledPin, OUTPUT); // Sets LED as an output.
}

float voltage = 0; // setup some variables
float voltage2 = 0;
float sensor = 0;
float celsius = 0;
float sensor2 = 0;
float celsius2 = 0;

void loop() { // let's get measurin'

sensorValue = analogRead(sensorPin); // Reads analog input.
sensorPin = celsius2; // Connects sensor value with analog input 2.
if (celsius2 >= 30.0) // Sets temperature level that LED turns ON.
digitalWrite(ledPin, HIGH); // Turns on LED
else
digitalWrite(ledPin, LOW); // Turns off LED
sensor = analogRead(0); // Analog input 0
sensor2 = analogRead(1); // Analog input 1
voltage = (sensor5000)/1024; // convert raw sensor value to millivolts
voltage = voltage-500; // remove voltage offset
celsius = voltage/10; // convert millivolts to Celsius
voltage2 = (sensor2
5000)/1024; // convert raw sensor value to millivolts
voltage2 = voltage2-500; // remove voltage offset
celsius2 = voltage2/10; // convert millivolts to Celsius2

lcd.print("Water Temp:"); // Prints "Water Temp:" on LCD Display
lcd.print(celsius,1); // Prints Temp from Sensor 1 (Analog Input 0)
lcd.setCursor(0, 1); // Selects line 2 on LCD Display
lcd.print("Oil Temp:"); // Prints "Oil Temp:" on LCD Display
lcd.print(celsius2,1); // Prints Temp from sensor 2 (Analog Input 1)
delay (1000); // Creates delay of 1 second
lcd.setCursor(0, 0); // Resets LCD display for next loop
delay(50); // 50ms Delay

int sensorPin = A1;   // Selects Analog input 2 as sensor

Are you using pin 1 or pin 2? The comments says one thing. The code says another.

sensorPin = celsius2; // Connects sensor value with analog input 2.

It does? How? Please explain what you think this statement is doing.

if (celsius2 >= 30.0) // Sets temperature level that LED turns ON.
 digitalWrite(ledPin, HIGH); // Turns on LED
 else
 digitalWrite(ledPin, LOW); // Turns off LED

celsius2 has not been assigned a value, yet. There is really no point in testing it.

sensorValue = analogRead(sensorPin); // Reads analog input.
sensor = analogRead(0); // Analog input 0
sensor2 = analogRead(1); // Analog input 1
lcd.print("Water Temp:"); // Prints "Water Temp:" on LCD Display
lcd.print(celsius,1); // Prints Temp from Sensor 1 (Analog Input 0)
lcd.setCursor(0, 1); // Selects line 2 on LCD Display
lcd.print("Oil Temp:"); // Prints "Oil Temp:" on LCD Display
lcd.print(celsius2,1); // Prints Temp from sensor 2 (Analog Input 1)
delay (1000); // Creates delay of 1 second
lcd.setCursor(0, 0); // Resets LCD display for next loop
delay(50); // 50ms Delay

It's pretty obvious what this code is doing, even to the most casual observer. The comments are not adding anything of value.

I have done alot of work since posting my program and will attach the new version.

Good. But you have more to do.

How do i introduce user settable alarm points ( to turn on led ) when certain temp reached ?

How will the user enter the values? You need some sort of input device.
How will the user see the current values? You need some sort of menu system, and some way to trigger the display of a menu.

Hi As this is the first time i have played with programming since is kid is a few basic PIC stuff. With Arduino i can unsterstand ( Sort off the Basis. I understand there are much more efficent then mine but I am learning with what i can find ( feel fre to recomds things ).

My Program Coles
Go thru Examples for Ideas !
Start with somthing similar and change it. First i had to read Analog Sensors in Accurate Celsuis. Then Display it on LCD. ( It scrolls each aswer in a continues line after line. After setting cursor points i solved this. Now i had 2 segment size blocks and the end of text to fix. As i changed println to print ( thanks Again ). All worked well.
Next stage was to have a analog reading ( if A3 went to Celsuis 2 it's My Mistake which i will fix.( I went A1,2,3. But did Celsius, Celsuis2 & 3 ) went
. Anyway with the attached software everything works , I believe i could have done things alot different.
I have the temp and the temp of the thermostat on line one
and the temp on line 2 ( thermo for this one is set to 30 and then turns on LED.
Jope this explains things.
PLease show me the best way to achieve what i have if you have any doubts please run the program.
*/
lcd 11,12 4,5,6,7 and 5V, GND,
pin = 13 set as Output to LED
Pin = 8 Set as Output to LED
Sensor TMP36 = A0 ( Sensor 0 )
Sensor2 POT ( to simulate TMP36 ) = Read Analog Input 1.
I think you get the picture when you read the rest. I will fix it up.

If required i will set circuits and photo's.
Please go easy it's my first evolving program.
P.S. You guys are great i hope i can help others some day.
If you would like to tell me the best books or sites to learn i would owe you.

I have tried to write what i think each line does, please correct me.
I AM GRATEFUL TO HAVE YOUR HELP. :wink:

Here is my code that Works how i hoped, 2 temp readings and to set points where certain things happen when temp reached. Also to display it on LCD.
Not bad for 2 days hey ??
:wink:

/*CREATED BY CHRIS COBLEY PROJECT No4, 3rd NOV 2010.
This Script has 2 analog inputs ( Temperature sensors ).
Displays Temps on LCD Display 2x16.
Converts Analog data to Degrees in Celsius.
Turns on a Digital output ( LED ) when a set temperature is reached.
Turns off LED when Temp below set level.

Thermostat Connections:
Pin 1 of TMP36 to Arduino 5V power socket
Pin 2 of TMP36 to Arduino analog 0 socket ( Thermostat No2 to Analog 1 ).
Pin 3 of TMP36 to Arduino GND socket

LCD Connections:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • Red to +5V
  • Black to ground
    */
    // includes the library code, so LCD diaplay works.
    #include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int ledPin = 13; // Select pin for LED
int ledPin1 = 8; // Select pin for LED
int sensorPin = A1; // Selects Analog input 2 as sensor
int sensorValue = 0; // Variable to store value from sensor
int sensorPin1 = A2; // Selects Analog input 2 as sensor
int sensorValue1 = 0; // Variable to store value from sensor
void setup() {

lcd.begin(16, 2); // Sets the number of rows & columns on LCD
pinMode(ledPin, OUTPUT); // Sets LED as an output.
pinMode(ledPin1, OUTPUT); // Sets LED as an output.
}

float voltage = 0; // setup some variables
float voltage2 = 0;
float voltage3 = 0;
float sensor = 0;
float sensor2 = 0;
float sensor3 = 0;
float celsius = 0;
float celsius2 = 0;
float celsius3 = 0;

void loop() { // let's get measurin'

sensorValue = analogRead(sensorPin); // Reads analog input.
sensorPin = celsius2; // Connects sensor value with analog input 2.
if (celsius2 >= 30.0) // Sets temperature level that LED turns ON.
digitalWrite(ledPin, HIGH); // Turns on LED
else
digitalWrite(ledPin, LOW); // Turns off LED
sensorValue1 = analogRead(sensorPin1); // Reads analog input.
sensorPin1 = celsius3; // Connects sensor value with analog input 2.
if (celsius >= celsius3) // Sets temperature level that LED turns ON.
digitalWrite(8, HIGH); // Turns on LED
else
digitalWrite(8, LOW); // Turns off LED

sensor = analogRead(0); // Analog input 0
sensor2 = analogRead(1); // Analog input 1
sensor3 = analogRead(2); // Analog input 2
voltage = (sensor5000)/1024; // convert raw sensor value to millivolts
voltage = voltage-500; // remove voltage offset
celsius = voltage/10; // convert millivolts to Celsius
voltage2 = (sensor2
5000)/1024; // convert raw sensor value to millivolts
voltage2 = voltage2-500; // remove voltage offset
celsius2 = voltage2/10; // convert millivolts to Celsius2
voltage3 = (sensor3*5000)/1024; // convert raw sensor value to millivolts
voltage3 = voltage3-500; // remove voltage offset
celsius3 = voltage3/10; // convert millivolts to Celsius2

lcd.print("Water T:"); // Prints "Water Temp:" on LCD Display
lcd.print(celsius,0); // Prints Temp from Sensor 1 (Analog Input 0)
lcd.setCursor(14,0);
lcd.print(celsius3,0); // Prints Temp from Sensor 1 (Analog Input 0)
lcd.setCursor(0, 1); // Selects line 2 on LCD Display
lcd.print("Oil T:"); // Prints "Oil Temp:" on LCD Display
lcd.print(celsius2,0); // Prints Temp from sensor 2 (Analog Input 1)
delay (1000); // Creates delay of 1 second
lcd.setCursor(0, 0); // Resets LCD display for next loop
delay(50); // 50ms Delay
}

I used programs that were close in truth i still do't know what Float & many other functions do. So far it has water temp on line one and the preset temp controlled by a pot ( analog input ).
Line two has another temp but the ref point turning on the LED is set manually to 30 and is not displayed.
I love Programming but only have self training to go on. You can Earn money with your assistance.

I used programs that were close in truth i still do't know what Float & many other functions do.

You could look here:

Programming is a matter of assembling building blocks in the correct order. If you know what each "block" does, and what its inputs and outputs are, you will have a much easier time assembling them in the correct order.

I love Programming but only have self training to go on.

Ultimately, that's all anybody has. Some understand the basics first, and have a much easier time. Some eventually come to understand the basics after much trial and error.

One thing to keep in mind is that the compiler, stupid as it seems to be sometimes, is ALWAYS right.

You can Earn money with your assistance.

Unless you are up against a deadline, this should be a last resort. There is a lot to be gained from learning how to do it yourself.

Now, if you needed brain surgery, I wouldn't recommend doing it yourself...

At least, give it a try. You'll have to do that, anyway, to get the user interface (the buttons) to work. One button causes the set point adjustment code loop to be entered. That button can also represent up or down in the loop, and you need another one for the other direction. A third button then causes a break out of that loop (like an OK button). You might consider having 4 buttons, so you can have two buttons break out of the loop - one for OK, the other for Cancel.