0

The issue I have right now is that the arduino uno programming software is asking me to put a comma or semicolon (sketch_apr04b:16: error: expected ',' or ';' before 'void') before void and I dont know why and when I do it tells me the same answer.

Here is my code

#include <Servo.h>;  

Servo servo;

void setup () {
  servo.attach(9);
  servo.write(0);
  Serial.begin(9600);
}

  int seconds = millis()/1000;
  int degs = 0;
  int time = 0;
  int runs = 0

void loop() {
  // put your main code here, to run repeatedly:
  seconds = millis();
  while(time <= 28) {
  Serial.write(seconds);
  degs = map(time, 0, 29, 0, 179);
  servo.write(degs);
  delay(1000);
  }
  runs = runs + 1;
  time = seconds * (runs*29)
  servo.write(0);
  time = 0;
}

4 Answers 4

1

Your code has three syntax errors:

Error 1:

All semicolons are used to mark the finish of statement. #include is not a statement so semicolons should not be included.

Error 2 and 3:

The same as before semicolons are used to delimiter of statement. Then you should include it in both lines.

#include <Servo.h>;  <----------------------- ERROR 1

Servo servo;

void setup () {
  servo.attach(9);
  servo.write(0);
  Serial.begin(9600);
}

  int seconds = millis()/1000;
  int degs = 0;
  int time = 0;
  int runs = 0 <----------------------------- ERROR 2

void loop() {
  // put your main code here, to run repeatedly:
  seconds = millis();
  while(time <= 28) {
  Serial.write(seconds);
  degs = map(time, 0, 29, 0, 179);
  servo.write(degs);
  delay(1000);
  }
  runs = runs + 1;
  time = seconds * (runs*29) <--------------- ERROR 3
  servo.write(0);
  time = 0;
}
Sign up to request clarification or add additional context in comments.

Comments

0

you forget two';' in your code after 'int runs =0 ;' and after

'time = seconds * (runs*29);'.

In arduino C each line must finish by a ;.

1 Comment

thanks a bunch it works now but looks like the Servo motor is glitching out a lot now
0

You forgot a semicolon, ";" after these lines

time = seconds * (runs*29)

and

int runs = 0

Comments

0

you are missing two ";" when you declare the 'runs" variable, and on 'time = seconds * (runs*29)'

    #include <Servo.h>;  

    Servo servo;

    void setup () {
      servo.attach(9);
      servo.write(0);
      Serial.begin(9600);
    }

      int seconds = millis()/1000;
      int degs = 0;
      int time = 0;
      int runs = 0 <---- HERE
void loop() {
  // put your main code here, to run repeatedly:
  seconds = millis();
  while(time <= 28) {
  Serial.write(seconds);
  degs = map(time, 0, 29, 0, 179);
  servo.write(degs);
  delay(1000);
  }
  runs = runs + 1;
  time = seconds * (runs*29)<----- HERE
  servo.write(0);
  time = 0;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.