Rereading and update if info has changed

This is my program it works but only as a one shot type of deal. it will only read through once and set the output one time, im needing it to read the info from the input continuously and if it changes update the output.
This is a converter for a temperature gauge on my car from an analog signal to a pwm signal im new to the arduino and programming any help would be appreciated.

#include <TimerOne.h>

//ECT converter from civic ek sensor to s2000 cluster
int ectOut = 9;
int ectIn = A1;
int adcValue=0; //ect voltage in range between 0 and 1023
unsigned long ectBars[7]={1500000,1100000,700000,400000,300000,220000,150000}; //microseconds from 1 to 7 segments
int ectADC[6]={203,156,122,84,53,19}; //correspondence between bars and temperature (in adc units) (71,82,93,104,115,126 celsius)
long waitUntil=0;
int update = 1000; //reading ect sensor only every 5 seconds
void setup()
{pinMode(ectOut, OUTPUT); //set the pin as output
pinMode(ectIn, INPUT); //set the pin as input
Timer1.initialize(); //initializing the Timer1,for use of pwm
Timer1.pwm(ectOut,20,1530000); // set the new custom pwm on Out pin
int adcValue = analogRead(ectIn); //read the ect voltage
// match the voltage to microseconds that represents x segments
if (ectIn= 0)
Timer1.pwm(ectOut,20,ectBars[0]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[5])
Timer1.pwm(ectOut,171,ectBars[6]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[4])
Timer1.pwm(ectOut,122,ectBars[5]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[3])
Timer1.pwm(ectOut,93,ectBars[4]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[2])
Timer1.pwm(ectOut,71,ectBars[3]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[1])
Timer1.pwm(ectOut,42,ectBars[2]+30000); // set the new custom pwm on ectOut pin
else if (analogRead(ectIn) <= ectADC[0])
Timer1.pwm(ectOut,27,ectBars[1]+30000); // set the new custom pwm on ectOut pin
else
Timer1.pwm(ectOut,20,ectBars[0]+30000);} // set the new custom pwm on ectOut pin
void loop(){
//we read ect sensor every 5 seconds

if (millis() >= waitUntil);
analogRead(ectIn);}

Your code is hard to read quickly. Just finding the { and matching } is a pain.

This block

if (ectIn= 0)
Timer1.pwm(ectOut,20,ectBars[0]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[5])
Timer1.pwm(ectOut,171,ectBars[6]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[4])
Timer1.pwm(ectOut,122,ectBars[5]+30000); // set the new custom pwm on ectOut pin
else if(analogRead(ectIn) <= ectADC[3])
Timer1.pwm(ectOut,93,ectBars[4]+30000); // set the new custom pwm on ectOut pin
 else if(analogRead(ectIn) <= ectADC[2])
Timer1.pwm(ectOut,71,ectBars[3]+30000); // set the new custom pwm on ectOut pin
 else if(analogRead(ectIn) <= ectADC[1])
Timer1.pwm(ectOut,42,ectBars[2]+30000); // set the new custom pwm on ectOut pin
else if (analogRead(ectIn) <= ectADC[0])
Timer1.pwm(ectOut,27,ectBars[1]+30000); // set the new custom pwm on ectOut pin
 else
Timer1.pwm(ectOut,20,ectBars[0]+30000);

Needs to be in a function that can be called from void loop().

Spread your code lines out a bit. Get the { and } on their own lines so it’s easy to see where blocks start and end.
Use empty lines to separate lines that do one thing from lines that do something else. Packed source is a pain every time you or someone else has to go back into it.

thank you for the input i’ll try that when i get off work tonight and see what happens

i tried to clean it up a little bit and i added a function but it doesnt out put the correct display on the cluster now i dont know if the scan rate is to high on the loop function that is causing it or what it is but now it just either reads the highest or lowest input all the time

void myLoopfunction()

{
if (ectIn= 0)
Timer1.pwm(ectOut,20,ectBars[0]+30000); // set the new custom pwm on ectOut pin

else if(analogRead(ectIn) <= ectADC[5])
Timer1.pwm(ectOut,171,ectBars[6]+30000); // set the new custom pwm on ectOut pin

else if(analogRead(ectIn) <= ectADC[4])
Timer1.pwm(ectOut,122,ectBars[5]+30000); // set the new custom pwm on ectOut pin

else if(analogRead(ectIn) <= ectADC[3])
Timer1.pwm(ectOut,93,ectBars[4]+30000); // set the new custom pwm on ectOut pin

else if(analogRead(ectIn) <= ectADC[2])
Timer1.pwm(ectOut,71,ectBars[3]+30000); // set the new custom pwm on ectOut pin

else if(analogRead(ectIn) <= ectADC[1])
Timer1.pwm(ectOut,42,ectBars[2]+30000); // set the new custom pwm on ectOut pin

else if (analogRead(ectIn) <= ectADC[0])
Timer1.pwm(ectOut,27,ectBars[1]+30000); // set the new custom pwm on ectOut pin

else
Timer1.pwm(ectOut,20,ectBars[0]+30000);} // set the new custom pwm on ectOut pin

void loop()
{
//read ect sensor every 5 seconds</timerone.h></timerone.h></timerone.h>
if (millis() >= waitUntil) ;

myLoopfunction;

analogRead(ectIn)+update;

}

Some fixing and yes the braces I add do not have to be there but I put them in for clarity.
Also not that I put the code inside of code tags (so the code formats right)

[code] ... sketch...  [/code]
void myLoopfunction()
{
  if (ectIn= 0)
  {                             // you forgot this one
    Timer1.pwm(ectOut,20,ectBars[0]+30000); // set the new custom pwm on ectOut pin
  }
  else if(analogRead(ectIn) <= ectADC[5])
  {
    Timer1.pwm(ectOut,171,ectBars[6]+30000); // set the new custom pwm on ectOut pin
  }
  else if(analogRead(ectIn) <= ectADC[4])
  {
    Timer1.pwm(ectOut,122,ectBars[5]+30000); // set the new custom pwm on ectOut pin
  }
  else if(analogRead(ectIn) <= ectADC[3])
  {
    Timer1.pwm(ectOut,93,ectBars[4]+30000); // set the new custom pwm on ectOut pin
  }
  else if(analogRead(ectIn) <= ectADC[2])
  {
    Timer1.pwm(ectOut,71,ectBars[3]+30000); // set the new custom pwm on ectOut pin
  }
  else if(analogRead(ectIn) <= ectADC[1])
  {
    Timer1.pwm(ectOut,42,ectBars[2]+30000); // set the new custom pwm on ectOut pin
  }
  else if (analogRead(ectIn) <= ectADC[0])
  {
    Timer1.pwm(ectOut,27,ectBars[1]+30000); // set the new custom pwm on ectOut pin
  }
  else
  {
    Timer1.pwm(ectOut,20,ectBars[0]+30000); // set the new custom pwm on ectOut pin
  }
}

Yup, extra typing and fits less code on a page but super easy to see what lines up, what does not.
Any time you find yourself trying to find a single typo in packed text, it will take longer and have more eyestrain.

I’m not young, less time to waste playing where’s waldo with code. I do things like this because it reads easier/quicker;

    Timer1.pwm( ectOut, 20, ectBars[ 0 ] + 30000 );

You can go looking through stacked lines formatted like that a lot easier than stacked and packed text.
It makes a bigger difference when you get away for a while and don’t instantly recognize what you just wrote or if it’s something that you didn’t write and have to figure out.

PS code windows on the forum can be resized with left-click and drag the lower right corner.