Strange Apearence of 5V

Hi,

i’m doing a code to Arduino, but i have a real problem with the Serial Monitor…

This is my code:

int PinAnalogA1 = 1; 
float valAnalog=0;  
int redPin=11; 
int yellowPin=12;
int greenPin=13; 

float tensao=0;

void setup() 
{
  Serial.begin(9600); 
  
    pinMode(redPin, OUTPUT);  
    pinMode(yellowPin, OUTPUT); 
    pinMode(greenPin, OUTPUT);  
}

void loop ()
{
 
    valAnalog = analogRead(PinAnalogA1);
    tensao = (valAnalog * 5.0) /1023;
    
    if(tensao< 2.0)
   {
     Serial.print(tensao, 1);
     Serial.print("\t");
     Serial.println(" Alarme!" );   
      
      digitalWrite(redPin, LOW);
      digitalWrite(greenPin, LOW);
      digitalWrite(yellowPin, HIGH);
      
   } else if (tensao >4) {
     Serial.print(tensao, 1);
     Serial.print("\t");
     Serial.println(" Alarme!" );   
      
      digitalWrite(redPin, HIGH);   
      digitalWrite(greenPin, LOW);
      digitalWrite(yellowPin, LOW);
   }
    else  { 
     Serial.print(tensao,1);
     Serial.println("\t");
      digitalWrite(redPin, LOW);   
      digitalWrite(greenPin, HIGH);
      digitalWrite(yellowPin, LOW);
}
 delay(1000);
}

In my Serial Monitor i i have this Values:

2.5
5.0 Alarme!
2.6
5.0 Alarme
2.5
5.0 Alarme!
2.7
5.0 Alarme!

I don’t now why 5.0 Alarme! is printing in the Serial Monitor…

anyone now why???

(deleted)

The only problem I see is mixing of integers and floats, but that shuold not cause the problem.

Are you sure this is all the code? Did you copy and paste or type it in?

What is connected to the pin?

I', expected only the values 2.3, 2.4, 2.5 or near that.

I don't urderstand why is printing 5.0 V Alarme!

Conected to the Pin A1 is circuit to Read Tension, that flow's with the temperature of one Transistor NTC, from a system to read Temperature! I read with the Multimetro and the tension, to the temperature in my room, is always bettween 2 and 2.5 V..

Strange to print 5V Alarme!

Problem with conecctions or Arduino, maybe?

(deleted)

spycatcher2k: Have you connected a ground?

problem SOLVED!!!! I change the Digital PINS and Ground and Works

You really should post your question ONCE. You have two threads going now. I answered in Strange Values in Serial Monitor.