Pololu Zumo 32u4 Motor Commands

I just need some help on how the code should be formatted. I have tried to run the examples for the motors and proximity sensors however every time it says error compiling. When I write my own code using the zumo 32u4 library it says either error compiling or expected identifier before numeric constant.

This is the code I wrote:
#include <Wire.h>
#include <Zumo32U4.h>

Zumo32U4Motors motors;

void setup() {
// put your setup code here, to run once:
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:

void Zumo32U4Motors::setLeftSpeed(int16_t, 50);
}

The line

void Zumo32U4Motors::setLeftSpeed(int16_t, 50);

should probably look more like

motors.setLeftSpeed(50);

Have you looked at the examples?

How Zumo32U4 "knows" what pins to use is beyond my understanding.

Also: You included Wire.h. I see that many of the examples do the same thing. I don't know why. I am going to assume that you are going to use it later. It does no harm except costs a tiny bit of compiling time.

This is the new code:

#include <Zumo32U4.h>

Zumo32U4Motors motors; //In order for motors.setLeftSpeed to work this line has to be added 
void setup() {
 // put your setup code here, to run once:
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
}

void loop() {
 // put your main code here, to run repeatedly:

motors.setLeftSpeed(50);

}

This is the error message I now get:

Arduino: 1.6.6 (Windows 7), Board: “Arduino Robot Control”

C:\Users\GunnarM\Documents\Arduino\libraries\Zumo32U4\Zumo32U4ProximitySensors.cpp: In function ‘bool digitalReadSafe(uint8_t, bool)’:

C:\Users\GunnarM\Documents\Arduino\libraries\Zumo32U4\Zumo32U4ProximitySensors.cpp:14:15: error: ‘NUM_DIGITAL_PINS’ was not declared in this scope

if (pin < NUM_DIGITAL_PINS)

^

C:\Users\GunnarM\Documents\Arduino\libraries\Zumo32U4\Zumo32U4ProximitySensors.cpp: In function ‘void pinModeSafe(uint8_t, uint8_t)’:

C:\Users\GunnarM\Documents\Arduino\libraries\Zumo32U4\Zumo32U4ProximitySensors.cpp:26:15: error: ‘NUM_DIGITAL_PINS’ was not declared in this scope

if (pin < NUM_DIGITAL_PINS)

^

C:\Users\GunnarM\Documents\Arduino\libraries\Zumo32U4\Zumo32U4ProximitySensors.cpp: In member function ‘void Zumo32U4ProximitySensors::lineSensorEmittersOff()’:

C:\Users\GunnarM\Documents\Arduino\libraries\Zumo32U4\Zumo32U4ProximitySensors.cpp:117:32: error: ‘NUM_DIGITAL_PINS’ was not declared in this scope

if (lineSensorEmitterPin < NUM_DIGITAL_PINS)

^

exit status 1
Error compiling.

I feel there is something missing regarding the pins and that is why it won’t run however can’t find anything that will specify which pin to run the command on. Based on the error message it feels like I have to declare the number of pins and the pin location but I am unable to figure out how.

Hi,

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Thanks… Tom… :slight_smile:

That error shows you selected “Arduino Robot Control” in the boards manager. Is this correct for the Zumo32u4? I can’t find on the website which board Pololu says you should use. You may need to use the boards manager to download the correct definition for the 32u4 board.

Happy New Year. Thanks for the help I found the problem. I didn't have a hardware folder under arduino so I never installed the board. Thank you now everything is working. :)