src/main.cpp:50:2: error: expected unqualified-id before ‘while’
while (!Wire.begin(I2C_SDA, I2C_SCL, 100000ul)) { // standard wire pins
^~~~~
src/main.cpp:55:5: error: ‘commander’ does not name a type
commander.addI2CMotors(TARGET_I2C_ADDRESS, 0); // only one motor in my test setup - *Need to add a second motor
^~~~~~~~~
src/main.cpp:56:5: error: ‘commander’ does not name a type
commander.addI2CMotors(TARGET_I2C_ADDRESS, 1); // Not sure if I’ve done this correctly
^~~~~~~~~
src/main.cpp:57:5: error: ‘commander’ does not name a type
commander.init();
^~~~~~~~~
src/main.cpp:58:5: error: ‘Serial’ does not name a type
Serial.println(“I2C Commander intialized.”);
^~~~~~
src/main.cpp:59:1: error: expected declaration before ‘}’ token
}
Does anyone feel like helping me make it compile? My C++ isn’t up to it.
This code makes no sense. The setup() function is closed on line 47 but then there’s this while loop just outside of any function, that’s not valid code. You may try to remove line 47.
When debugging compiler errors, the first one usually causes many of the others, so never mind that you might have 200 errors (like I usually have!) the chances are that most will be resolved by fixing the first one.
Also, if the error messages says something is expected before something, have a look before the indicated line. That’s usually the reason. The compiler found something it wasn’t happy with and didn’t “understand” so it ignored everything until it managed to re-synchronise at the next, or a new, source line. Then it complains about not understanding something before that point.
It’s usually relatively easy when you get the hang of it.