Program error

I need help…I have an error (stray) can anyone help me?

#include <LiquidCrystal.h>
#include <Servo.h>
Servo myservo;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int num = 0;
int numvaga = 8;
int sensorVaga8 = A4;
int sensorValue8 = 0;
int sensorVaga6 = A2;
int sensorValue6 = 0;
int sensorVaga7 = A3;
int sensorValue7 = 0;
int sensorVaga3 = A5;
int sensorValue3 = 0;
int recByte;
boolean entrar = false;
boolean sair = false;

void sensorvaga3() {
if (sensorValue3 < 200) {
num = 8;
Serial.write(num);
}
if (sensorValue3 > 200) {
num = 9;
Serial.write(num);
}
}

void sensorvaga6() {
if (sensorValue6 < 200) {
num = 2;
Serial.write(num);
}
if (sensorValue6 > 200) {
num = 3;
Serial.write(num);
}
}

void sensorvaga7() {
if (sensorValue7 < 200) {
num = 4;
Serial.write(num);
}
if (sensorValue7 > 200) {
num = 5;
Serial.write(num);
}
}

void sensorvaga8() {
if (sensorValue8 < 200) {
num = 6;
Serial.write(num);
}
if (sensorValue8 > 200) {
num = 7;
Serial.write(num);
}
}

void lcd2()
{
if (recByte == 6)
{
lcd.setCursor(0, 0);
lcd.print (“Seja Bem vindo”);
lcd.setCursor(0, 1);
lcd.print (“Vagas: ala A e B”);
}
else if (recByte == 3)
{
lcd.setCursor(0, 0);
lcd.print (“Desculpe “);
lcd.setCursor(0, 1);
lcd.print (“Vagas esgotadas”);
}

else if (recByte == 5)
{
lcd.setCursor(0, 0);
lcd.print (“Seja Bem vindo”);
lcd.setCursor(0, 1);
lcd.print (“Vagas: ala B “);
}
else if (recByte == 4)
{
lcd.setCursor(0, 0);
lcd.print (“Seja Bem vindo”);
lcd.setCursor(0, 1);
lcd.print (“Vagas: ala A “);
}

}
void setup() {
Serial.begin(9600);
numvaga = 8;
lcd.begin (16, 2);
lcd.setCursor(0, 0);
lcd.print (“Seja Bem vindo”);
lcd.setCursor(0, 1);
lcd.print (“Vagas: ala A e B”);
}

void loop() {
if (Serial.available() > 0) {
recByte = Serial.read();
}

sensorValue6 = analogRead(sensorVaga6);
sensorValue7 = analogRead(sensorVaga7);
sensorValue8 = analogRead(sensorVaga8);
sensorValue3 = analogRead(sensorVaga3);

sensorvaga6();
sensorvaga7();
sensorvaga8();
sensorvaga3();
lcd2();
}

Hi,
Welcome to the forum.

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

It will format the sketch in the window and make it easier to read.

What do you mean by stray error?
What is your application?
What does your sketch do and not do?
What arduino board are you usuing?
What version IDE?

Thanks Tom… :slight_smile:

When I compile the code you posted incorrectly, I get:

Binary sketch size: 7,272 bytes (of a 28,672 byte maximum)

Hi,
I noticed in your sketch this;

 sensorValue6 = analogRead(sensorVaga6);
  sensorValue7 = analogRead(sensorVaga7);
  sensorValue8 = analogRead(sensorVaga8);
  sensorValue3 = analogRead(sensorVaga3);

You are reading consecutive analog inputs.
This can lead to your analog readings appearing to be unstable or have crosstalk.
The arduino only has one AtoD converter, so it switches from one input to the next, doing a conversion at each input.
A problem can occur when reading consecutively, because it takes time for the AtoD to obtain a correct input level, due to a capacitor on the AtoD input.
This time can be longer than the time it takes to read one input then the next.
The trick is to read each input twice, the last value being valid, all you need to do is this;

 sensorValue6 = analogRead(sensorVaga6);
  sensorValue6 = analogRead(sensorVaga6);
  sensorValue7 = analogRead(sensorVaga7);
  sensorValue7 = analogRead(sensorVaga7);
  sensorValue8 = analogRead(sensorVaga8);
  sensorValue8 = analogRead(sensorVaga8);
  sensorValue3 = analogRead(sensorVaga3);
  sensorValue3 = analogRead(sensorVaga3);

Tom...... :slight_smile: