Not sure how to word this with arduino statements

I have a temp sensor and an LCD screen. I want the LCD screen to display the readings from the temp sensor (which it does)but when the readings from the temp sensor equal a thousand then I want the LCD screen to display in this case a bar graph until the readings from the temp sensor are less than 700. Then I want the LCD screen to go back to displaying the readings from the temp sensor. I think the answer is relatively simple but I’m not sure how to word this so Arduino would understand. If you’re curious here is my code so far:

#include <LiquidCrystal.h>

#define lenght 16.0
double percent=100.0;
unsigned char b;
unsigned int peace;

LiquidCrystal lcd(4,5,6,7,8,9);

byte p1[10] = {
 0x10,
 0x10,
 0x10,
 0x10,
 0x10,
 0x10,
 0x10,
 0x10};


byte p2[10] = {
 0x18,
 0x18,
 0x18,
 0x18,
 0x18,
 0x18,
 0x18,
 0x18};

byte p3[10] = {
 0x1C,
 0x1C,
 0x1C,
 0x1C,
 0x1C,
 0x1C,
 0x1C,
 0x1C};

byte p4[10] = {
 0x1E,
 0x1E,
 0x1E,
 0x1E,
 0x1E,
 0x1E,
 0x1E,
 0x1E};

byte p5[10] = {
 0x1F,
 0x1F,
 0x1F,
 0x1F,
 0x1F,
 0x1F,
 0x1F,
 0x1F};

void setup()   {

 delay(100);
 lcd.createChar(0, p1);
 lcd.createChar(1, p2);
 lcd.createChar(2, p3);
 lcd.createChar(3, p4);
 lcd.createChar(4, p5);
 lcd.begin(16, 2);

}

void loop()
{

 lcd.setCursor(0, 0);



 unsigned int value = analogRead(0);
 if(value++){
   lcd.write("Temp");
   lcd.write('=');
   lcd.print(value-609);

 }
 if(value==1000){
   lcd.clear();

   while(value--){

     if(value<700){
       lcd.clear();

       break;
     }

     percent = (value-700.0)/(1000.0-700.0)*100.0;

     lcd.print(value);

     lcd.print(" - ");

     lcd.print(percent);
     lcd.print(" %   ");

     lcd.setCursor(0,1);

     double a=lenght/100*percent;




     if (a>=1) {

       for (int i=1;i<a;i++) {

         lcd.print((char)4);

         b=i;
       }

       a=a-b;

     }

     peace=a*5;



     switch (peace) {

     case 0:
       break;
     case 1:
       lcd.print((char)0);
       break;

     case 2:
       lcd.print((char)1);

       break;
     case 3:
       lcd.print((char)2);

       break;
     case 4:
       lcd.print((char)3);
       break;


     }
     lcd.clear();

   }
 }
}

I think I’m pretty close to getting it to do what I wanted to do. But right now it does one of two things 1. because I have the LCD.Clear at the end when the temperature reaches 1000 it displays the way I want it to or so it seems but the LCD screen clears so much I can barely see it. When I put in a delay after the LCD.Clear command then the LCD doesn’t display anything at all. Or 2.if I take out the LCD.Clear command then the LCD screen when the temperature reaches a thousand would display the bar graph but on the first row it would say for example 999 - 99.9% or 1000 - 100. 0% those numbers would remain the same until the temperature would reach less than 700 so the top row wouldn’t display the current readings while the bottom row would display the bar graph but it the bar graph would go from a hundred percent down to 0% while the bar graph is going from 100% down to 0% the bottom row starts to display the correct information that the top row should be displaying. So really its all messed up without that LCD.Clear command. Any help is much appreciated.

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

You have some strange stuff

if(value++){

and

  while(value--){

what are these supposed to do ?

I think all you need is something like this

if (value >= 1000) {
  displayBars();
}
else {
  displayValues();
}

where displayBars() is a function that does what it says ... etc

...R

well I was trying to say when the value is increasing (++) do this, when decreasing (–) do this, n oh ok so if I said something like

if (value >= 1000) {
displayBars();
}
else if (value <700){
displayValues();
}

then it would display values until it reaches 1000 or greater then display the bar and when the value goes back down to 700 it would display the values again?

blu11sonic: well I was trying to say when the value is increasing (++) do this, when decreasing (--) do this, n oh ok

I suspected you had something like that in mind - but that code does not do that. myVar ++; is the same as myVar = myVar + 1; and also the same as myVar += 1;

If you want to check if something is increasing you need something like if (newVal > prevVal)

then it would display values until it reaches 1000 or greater then display the bar and when the value goes back down to 700 it would display the values again?

That is what I intended - is it what you want ?

It is good practice to get in the habit of writing short programs to try out new concepts. Keep the program as short as it possibly can be.

...R

oh ok, and ya that's what I want but when I apply that code there's kinda a gray area so when the temp is over 700 the lcd would freeze at "temp=700" until the value is greater than or equal to 1000 then it would display the bar graph but the graph would be frozen at 100% until the value is less than 700.

blu11sonic: oh ok, and ya that's what I want but when I apply that code there's kinda a gray area so when the temp is over 700 the lcd would freeze at "temp=700" until the value is greater than or equal to 1000 then it would display the bar graph but the graph would be frozen at 100% until the value is less than 700.

So, change the values in the tests, or introduce a third category. With a little ingenuity you could make it wait to change up at 1000 and wait until it gets to 700 to change back.

I don't understand what you mean by "frozen" - that sounds like it has nothing to do with the tests.

...R