0
votes

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

4 Answers

1
votes

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;
}
0
votes

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 ;.

0
votes

You forgot a semicolon, ";" after these lines

time = seconds * (runs*29)

and

int runs = 0
0
votes

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;
}