HELP! Mulitple errors, not sure why

I am brand new to Arduino. Normally I'm one to wrestle with something like this until I get it on my own, but I'm up against a deadline on this and frankly I'm in over my head. Jokes at my expense are expected, I just need to get this ironed out ASAP.

My entire code is below, followed by the errors I am getting. I actually had this working, tried to add a feature, like an idiot didn't save a copy first, now I can't even clear the errors when I remove everything I thought I added.

Thanks in advance.

//Heading Query
int val;
int old_Status
//Rudder
#include <Servo.h>
Servo rudder;
//Port Thruster
int motorpin1 = 11, motorpin2 = 10;
//Starboard Thruster
int motorpin3 = 9, motorpin4 = 6;
//Vertical Thruster
int motorpin5 = 5, motorpin6 = 3;
//Water Current Direction Sensor
int directionpin = A3;
int var;
//Distance Sensor
int trig = 12;
int echo = 13;
float distance;
float time;


//SETUP
void setup()
{
//Serial Startup
  Serial.begin(9600);
  
  Serial.println("Is Heading Correct? Y or N?");
  
//Rudder
  pinMode(A2, OUTPUT);
  rudder.attach(A2);
  
//Port Thruster
  pinMode(motorpin1, OUTPUT);
  pinMode(motorpin2, OUTPUT);
  
//Starboard Thruster
  pinMode(motorpin3, OUTPUT);
  pinMode(motorpin4, OUTPUT); 
  
//Vertical Thruster
  pinMode(motorpin5, OUTPUT);
  pinMode(motorpin6, OUTPUT); 
  
//Water Current Direction Sensor
  pinMode(directionpin, INPUT);  
  
//Distance Sensor  
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
}

//LOOP
void loop()
  {
  
//Heading Query
  if (Serial.available()){ 
   val = Serial.read();
  }
    if(val = 'Y'){
  Serial.println("Yes");
  }
  
//Distance Sensor
   {
   digitalWrite(trig, LOW);
   delayMicroseconds(2);
   digitalWrite(trig, HIGH);
   delayMicroseconds(10);
   digitalWrite(trig, LOW);
   time = pulseIn(echo, HIGH);
   distance = time/148.1;
   }
    
//Rudder & Side Thrusters
   int potenValue = analogRead(A3);
   float dirValue = potenValue * (5.0 / 1023.0);

   if (dirValue < 2){  
   //Bear to Port
   rudder.write(135);
   analogWrite(motorpin1, 0); 
   analogWrite(motorpin2, 127); 
   analogWrite(motorpin3, 0); 
   analogWrite(motorpin4, 255); 
   }
   //Bear to Starboard
   else if (dirValue > 3){ 
   rudder.write(45);
   analogWrite(motorpin1, 255); 
   analogWrite(motorpin2, 0); 
   analogWrite(motorpin3, 127); 
   analogWrite(motorpin4, 0) ; 
   }  
   //Straight
   else { 
   rudder.write(90);
   analogWrite(motorpin1, 127); 
   analogWrite(motorpin2, 0); 
   analogWrite(motorpin3, 0); 
   analogWrite(motorpin4, 127); 
   }

//Vertical Thruster
   if (distance < 100 & distance >= 30){
   analogWrite(motorpin5, 127); 
   analogWrite(motorpin6, 0) ; 
   }
   else if (distance < 30){
   analogWrite(motorpin5, 255); 
   analogWrite(motorpin6, 0) ; 
   }  
   else {
   analogWrite(motorpin5, 0); 
   analogWrite(motorpin6, 127) ; 
   }
  }
//Heading Query Else
 else {
  Serial.print ("No");  
 
  //Turn to Starboard
  rudder.write(45);
  analogWrite(motorpin1, 255); 
  analogWrite(motorpin2, 0); 
  analogWrite(motorpin3, 127); 
  analogWrite(motorpin4, 0); 
  }
63:0,
5:
57:1: error: expected initializer before 'typedef'


57:41: error: 'timer16_Sequence_t' does not name a type


122:2: error: expected unqualified-id before 'else'
 exit status 1

missing a semicolon after

and indent the code (done by pressing ctrlT on a PC or cmdT on a Mac), you'll likely see mismatched braces

And you should switch on warnings in the IDE. There are some statements that most likely will not do what you want them to do - even if they are syntactically correct ( no error ). But the compiler throws a warning - he knows about such semantically errors :wink: .

Dude! That was it! I knew it was going to be something stupid, you just look at something for so long, you start going cross eyed. Thank you!

we have all been there at least once (and then we learnt that when the compiler's error message seems cryptic, then it's important to look above the line with the issue)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.