So I've just written my code for a project and I'm getting this error. Google has provided me with no answers and I'm going out of my mind trying to figure out the problem, I've been at it all day so maybe a fresh set of eyes will help.
I know there's many out there that will say theres a better way to write the code but for my own understanding I've written it this way for simplicity sake. When I gain a better knowledge of coding I'll rewrite it.
//Variable Declarations
const int posA = 9;
const int posB = 10;
const int posC = 11;
const int ledPin = 13;
const int soundPin = A0;
int threshold1 = 1021;
int threshold2 = 800;
int threshold3 = 600;
//Testing for ammo belt
int belt1 = 30;
int belt2 = 35;
int belt3 = 40;
int newVal;
//Setup functions
void setup()
{
//Switch setup
pinMode(posA,INPUT_PULLUP);
pinMode(posB,INPUT_PULLUP);
pinMode(posC,INPUT_PULLUP);
//LED and Serial setup
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
//Main loop of code
void loop()
{
//Read the switch position
int stateA = digitalRead(posA);
int stateB = digitalRead(posB);
int stateC = digitalRead(posC);
//Read the value of the analog oin
int value = analogRead(soundPin);
/*Serial.println(value);
delay(50);*/
if(stateA == HIGH)
{
//If the sound is above the threshold do this
if(value > threshold1)
{
belt1 = belt1-1;
Serial.println(belt1);
digitalWrite(ledPin,HIGH);
//Serial.println("LOUD");
delay(200);
}
}
//Otherwise do this
else if (stateB == HIGH)
{
if(value > threshold2)
{
belt2 = belt2-1;
Serial.println(belt2);
digitalWrite(ledPin,HIGH);
//Serial.println("LOUD");
delay(200);
}
}
else(stateC == HIGH)
{
if(value > threshold3)
{
belt3 = belt3-1;
Serial.println(belt3);
digitalWrite(ledPin,HIGH);
//Serial.println("LOUD");
delay(200);
}
}
}
I've tried a good few things already, nothing seems to work. From my understanding this error code is one where I'm missing a syntax but I cant for the life of me see where I'm missing it.