leogsd1:
my problem is that the values that I get from the photocells overlap each other.
First, please use code tags around your posted code. Second, please post entire, compilable code.
the 1:30 PM values kind of go inside the 1 PM value range? I am trying to display this; however I am not able to get get the serial monitor to show the 1:30 PM even though I get the value of photocell in that range, It only shows 1 PM. PLEASE HELP!
Hmm.. looks OK to me, but then I don't have the entire code, so what you posted has no context.
Here's your code, but wrapped in a for loop, and with a few added Serial.print statements.
void setup() {
Serial.begin(115200);
for (int(average) = 328; average < 390; average++) {
Serial.print("Avg: ");
Serial.print(average);
Serial.print(" ");
if ((average > 316 && (average < 386)))
{
Serial.print ("1 pm ");
}
if ((average > 387 && (average < 488)))
{
Serial.print("2pm ");
}
if ((average > 330 && (average < 375)))
{
Serial.print("1.30 PM ");
}
Serial.println();
}
}
void loop() {
}
If you start a new sketch, paste this into it, and run it, you'll see that it works just as you seem to want it.
Here's a bit of the output:
Avg: 328, 1 pm
Avg: 329, 1 pm
Avg: 330, 1 pm
Avg: 331, 1 pm 1.30 PM
Avg: 332, 1 pm 1.30 PM
...
Avg: 373, 1 pm 1.30 PM
Avg: 374, 1 pm 1.30 PM
Avg: 375, 1 pm
Avg: 376, 1 pm
Avg: 377, 1 pm
Avg: 378, 1 pm
Avg: 379, 1 pm
Avg: 380, 1 pm
Avg: 381, 1 pm
Avg: 382, 1 pm
Avg: 383, 1 pm
Avg: 384, 1 pm
Avg: 385, 1 pm
Avg: 386,
Avg: 387,
Avg: 388, 2pm
Avg: 389, 2pm
Note the output for averages of 386 and 387. You probably want to adjust your if conditions.