how to read analog value continuous with Serial.read()

As it is currently written your program will only read the analogue inputs whilst there is something in the serial buffer.
Is that how you want it to work ?

i want serial monitor to monitoring continuous like a loop , not single value.

 case 'a':
     while(Serial.available() != 0);{
       Serial.println(sensorValue1);
  }
       break;

Thanks , Grumpy_Mike

but this not work ,program still monitoring single value.

mickeleckorn:
i want serial monitor to monitoring continuous like a loop , not single value.

Can you please describe what the program should do ? That might help understand exactly what you mean.

Read this before posting a programming question

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

sorry again for my bad english skill

i want my program to receive analog value from analog pin A0 A1 A2 selected by type and send letters in serial monitor.

now i use switch case for my program , but this serial monitor display single value, i want this to monitoring value continuous like in a loop.

Why do you keep your requirements secret?
Reply #8 showed you how why are you ignoring it?

sorry again for my bad english skill

They are probably not good enough for you to understand any answer.

The problem with your program, is that it is only going to read the analog inputs, when there is a character from
you arriving at the Arduino's serial input.

So unless you send characters to the arduino very often, you won't get a reading very often.

i'm not ignoring it but this not work ,program still monitoring single value same the old.

I'm not sure what you're trying to do, but is it: read a character from serial and then keep sending the analog reading it selected?

If so, you need to shorten the first if statement so that all it does is check for serial.available and read a character if one is there.

All the rest of your code needs to run every time loop runs. As you have it, all your code is controlled by serial.avaialble. If there's no serial input, nothing else happens.

Thanks, but after i remove the first if statement serial monitor displayed single analogvalue same the old.

const int ledPin = 13;
void setup() {
 
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(9, OUTPUT);
}


void loop() {
   
  int sensorValue1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);
  int sensorValue3 = analogRead(A2);
  int light_sensitivity = 500;
  int incomingByte;
  
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
  
  switch (incomingByte) {
    
    case 'a':
       Serial.println(sensorValue1);
       break;
    case 'b':
       Serial.println(sensorValue2);
       break;
    case 'c':
       Serial.println(sensorValue3);
       break;
    case 'H':
       digitalWrite(ledPin, HIGH);
       break;
    case 'L':
       digitalWrite(ledPin, LOW);
       break;
  }
    if (sensorValue3 < light_sensitivity) 
      {
        digitalWrite(9, HIGH);
      }
     else
      {
        digitalWrite(9, LOW);
        
      }
      delay(300);
    }
    // read the oldest byte in the serial buffer:
if(Serial.available())
{
    incomingByte = Serial.read();
}

thanks again , but this monitoring single value same the old.

const int ledPin = 13;
void setup() {
 
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(9, OUTPUT);
}


void loop() {
   
  int sensorValue1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);
  int sensorValue3 = analogRead(A2);
  int light_sensitivity = 500;
  int incomingByte;
  
    // read the oldest byte in the serial buffer:
    if(Serial.available()){
    incomingByte = Serial.read();
    }
  switch (incomingByte) {
    
    case 'a':
       Serial.println(sensorValue1);
       break;
    case 'b':
       Serial.println(sensorValue2);
       break;
    case 'c':
       Serial.println(sensorValue3);
       break;
    case 'H':
       digitalWrite(ledPin, HIGH);
       break;
    case 'L':
       digitalWrite(ledPin, LOW);
       break;
  }
    if (sensorValue3 < light_sensitivity) 
      {
        digitalWrite(9, HIGH);
      }
     else
      {
        digitalWrite(9, LOW);
        
      }
      delay(300);
    }

Can you have another go at explaining what you want it to do?

That looks like it will keep reporting one sensor value (which may vary) until you tell it to report another by sending another character.

i want my program to receive analog value from analog pin A0 A1 A2 selected by sending character in serial monitor.

Make incomingbyte static?

Thanks all i'm finish my code, serial monitor can read analog value continuous now.

  const int ledPin = 13;
void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(9, OUTPUT);
}
int incomingByte;
void loop() {
  int sensorValue1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);
  int sensorValue3 = analogRead(A2);
  if (Serial.available() ) {
  // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
   }
  switch (incomingByte) {
    case 'a':
       Serial.println(sensorValue1);
       break;
    case 'b':
       Serial.println(sensorValue2);
       break;
    case 'c':
       Serial.println(sensorValue3);
       break;
    case 'H':
       digitalWrite(ledPin, HIGH);
       break;
    case 'L':
       digitalWrite(ledPin, LOW);
       break;
  }
    delay(300);
    }

but this not work ,program still monitoring single value.

Have you set the serial monitor to not send any new line characters?
Select "no line ending" from the drop down at the bottom corner of the window.