Hello everyone, I've a problem and I need you to resolve it,
Look my code and let's me explain my aim:
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()){
char lumi = Serial.read();
if (lumi == 'l')
{
int luminosity = analogRead(A0);
Serial.println(luminosity);
Serial.print("\n");
}
}
if (Serial.available()){
char temp = Serial.read();
if (temp == 't')
{
int temperature_sensor = analogRead(A1);
float mv = ( temperature_sensor/1024.0)*5000;
float cel = mv/10;
Serial.println(cel);
Serial.print("\n");
}
}
}
So, my program consist of display the temperature or the luminosity, if I type the character t or l in the Serial Monitor. However when I write t or l, the value does not display instantly and I need to spam to display this value. It's from there that I need you to help me solve my problem.