1

Me and my friend have a project to do and we can't seem to figure out why the code we used for our Arduino Nano Board isn't compiling giving us the Expected ')' before ';' token Error

Here is the code:

// connect motor controller pins to Arduino digital pins
// motor one
int enA = 10;
int in1 = 9;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
void setup()
{
 // set all the motor control pins to outputs
 pinMode(enA, OUTPUT);
 pinMode(enB, OUTPUT);
 pinMode(in1, OUTPUT);
 pinMode(in2, OUTPUT);
 pinMode(in3, OUTPUT);
 pinMode(in4, OUTPUT);
}
void demoOne()
{
 // this function will run the motors in both directions at a fixed speed
 // turn on motor A
 digitalWrite(in1, HIGH);
 digitalWrite(in2, LOW);
 // set speed to 200 out of possible range 0~255
 analogWrite(enA, 200);
 // turn on motor B
 digitalWrite(in3, HIGH);
 digitalWrite(in4, LOW);
 // set speed to 200 out of possible range 0~255
 analogWrite(enB, 200);
 delay(2000);
 // now change motor directions
 digitalWrite(in1, LOW);
 digitalWrite(in2, HIGH); 
 digitalWrite(in3, LOW);
 digitalWrite(in4, HIGH); 
 delay(2000);
 // now turn off motors
 digitalWrite(in1, LOW);
 digitalWrite(in2, LOW); 
 digitalWrite(in3, LOW);
 digitalWrite(in4, LOW);
}
void demoTwo()
{
 // this function will run the motors across the range of possible speeds
 // note that maximum speed is determined by the motor itself and the operating voltage
 // the PWM values sent by analogWrite() are fractions of the maximum speed possible 
 // by your hardware
 // turn on motors
 digitalWrite(in1, LOW);
 digitalWrite(in2, HIGH); 
 digitalWrite(in3, LOW);
 digitalWrite(in4, HIGH); 
 // accelerate from zero to maximum speed
 for (int i = 0; i ; 256; i++)
 {
 analogWrite(enA, i);
 analogWrite(enB, i);
 delay(20);
 } 
 // decelerate from maximum speed to zero
 for (int i = 255; i (&gt);= 0; --i)
 {
 analogWrite(enA, i);
 analogWrite(enB, i);
 delay(20);
 } 
 // now turn off motors
 digitalWrite(in1, LOW);
 digitalWrite(in2, LOW); 
 digitalWrite(in3, LOW);
 digitalWrite(in4, LOW); 
}
void loop()
{
 demoOne();
 delay(1000);
 demoTwo();
 delay(1000);
}

We could really use some help.

gre_gor
1,6824 gold badges18 silver badges28 bronze badges
asked Feb 9, 2017 at 10:37

1 Answer 1

4

Well, for example for doesn't have four parts but three

for (int i = 0; i ; 256; i++) // => for (int i = 0; i < 256; ++i)

Next one doesn't look much better:

for (int i = 255; i (&gt);= 0; --i) // => for (int i = 255; i >= 0; --i)

There might be more, but these are really obvious. Like you copied it from some website with some characters translated into the html entities.

answered Feb 9, 2017 at 10:43
2
  • Thank you very much,yes indeed we copied the code from a website,thank you for helping us! Commented Feb 9, 2017 at 10:49
  • If this answer solves your issue and was useful please up vote and accept it Commented Feb 10, 2017 at 17:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.