# expected initializer before '\<' token error when compiling

**URL:** <https://forum.arduino.cc/t/expected-initializer-before-token-error-when-compiling/295705>\
**Category:** Programming\
**Created:** [March 7, 2015, 12:55am UTC](https://forum.arduino.cc/t/expected-initializer-before-token-error-when-compiling/295705 "2015-03-07T00:55:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 7, 2015, 12:55am UTC](https://forum.arduino.cc/t/expected-initializer-before-token-error-when-compiling/295705/1 "2015-03-07T00:55:13Z")

</div>

I'm working on a proof of concept prototype for my design thesis, and have run into this error that I can't figure out. I'm a total beginner with arduino and coding, and really appreciate any and all help I can get.

```cpp
#include <Wire.h>
#include "Adafruit_DRV2605.h"

const int TOTAL_MOTORS = 4;

Adafruit_DRV2605 drv;
int motorNumber = 0; 

void setup() {
  
  Serial.begin(9600);
  Serial.println("DRV test");

  // Pins for four motor controllers
  for (int i=0, i<TOTAL_MOTORS, i++ )
  {
    pinMode(2, OUTPUT);
  }
  
}

void loop() {
  
  programHaptic(motorNumber);
  motorNumber = (motorNumber + 1) % TOTAL_MOTORS;
  delay(2000);

}

void programHaptic (int h) {
  
  // Turn on h, turn off everything else
  for (int i=0, i<TOTAL_MOTORS, i++) {
    if (i==h) {
      digitalWrite (2+i, HIGH);
    } else {
      digitalWrite (2+i, LOW);
    }
  }
  
  // Initialize, program, and start motor
  drv.begin ();
  drv.setMode(DRV2605_MODE_INTTRIG); // default, internal trigger when sending GO command
  drv.selectLibrary(1);
  drv.setWaveform(0, 52);
  drv.setWaveform(1, 1);
  drv.setWaveform(2, 0);
  drv.go();

}

```

That is entire thing, and when I try and compile it to upload, I get the following error, with line 15 highlighted:

expected initializer before '\<' token

```cpp
Vibrate_Motor_Test_2_2.ino: In function 'void setup()':
Vibrate_Motor_Test_2_2:15: error: expected initializer before '<' token
Vibrate_Motor_Test_2_2:20: error: expected primary-expression before '}' token
Vibrate_Motor_Test_2_2:20: error: expected `;' before '}' token
Vibrate_Motor_Test_2_2:20: error: expected primary-expression before '}' token
Vibrate_Motor_Test_2_2:20: error: expected `)' before '}' token
Vibrate_Motor_Test_2_2:20: error: expected primary-expression before '}' token
Vibrate_Motor_Test_2_2:20: error: expected `;' before '}' token
Vibrate_Motor_Test_2_2.ino: In function 'void programHaptic(int)':
Vibrate_Motor_Test_2_2:33: error: expected initializer before '<' token
Vibrate_Motor_Test_2_2:50: error: expected primary-expression at end of input
Vibrate_Motor_Test_2_2:50: error: expected `;' at end of input
Vibrate_Motor_Test_2_2:50: error: expected primary-expression at end of input
Vibrate_Motor_Test_2_2:50: error: expected `)' at end of input
Vibrate_Motor_Test_2_2:50: error: expected statement at end of input
Vibrate_Motor_Test_2_2:50: error: expected `}' at end of input

```

Please don't rail me too hard, I realize it's probably something pretty basic in the grand scheme of things, but it's really difficult for me as I'm just trying to learn and wrap my head about it.

Thanks in advance for any help!

---

<div class="post-metadata">

**Author:** ![SurferTim](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/surfertim/32/1072341_2.png) [@SurferTim](https://forum.arduino.cc/u/SurferTim)\
**Post date:** [March 7, 2015, 1:20am UTC](https://forum.arduino.cc/t/expected-initializer-before-token-error-when-compiling/295705/2 "2015-03-07T01:20:20Z")

</div>

Replace the commas in both the for statement with semicolons.

```cpp
  for (int i=0; i<TOTAL_MOTORS; i++ )

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 7, 2015, 10:44pm UTC](https://forum.arduino.cc/t/expected-initializer-before-token-error-when-compiling/295705/3 "2015-03-07T22:44:13Z")

</div>

SurferTim, you are my hero.

Thank you so much!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 9:10pm UTC](https://forum.arduino.cc/t/expected-initializer-before-token-error-when-compiling/295705/4 "2021-05-05T21:10:00Z")

</div>

Closed on May 5, 2021, 9:10pm UTC


