I am writing code to read and control the 25mm DC encoder motor using the encoder motor driver/motor that came with the Ultimate kit. I have this code:
#include “MeMegaPi.h”
MeEncoderMotor motor1(PORT3B);
uint8_t motorSpeed = 100;
float position;
void setup()
{
}
void loop()
{
position = motor1.getCurrentPosition();
}
And it throws these errors:
/var/folders/0z/lj1rq4wx6j7c8p9l_76wx19c0000gn/T//ccP3NySS.ltrans0.ltrans.o: In function request': /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:520: undefined reference to
Wire’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:520: undefined reference to Wire' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:520: undefined reference to
TwoWire::beginTransmission(unsigned char)’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:522: undefined reference to Wire' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:522: undefined reference to
Wire’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:522: undefined reference to TwoWire::write(unsigned char const*, unsigned int)' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:524: undefined reference to
Wire’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:524: undefined reference to Wire' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:524: undefined reference to
TwoWire::endTransmission()’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:526: undefined reference to Wire' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:526: undefined reference to
Wire’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:526: undefined reference to TwoWire::requestFrom(int, int)' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:528: undefined reference to
Wire’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:528: undefined reference to Wire' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:528: undefined reference to
TwoWire::available()’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:530: undefined reference to Wire' /Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:530: undefined reference to
Wire’
/Users/garyboerger/Documents/Arduino/libraries/makeblock/src/MeEncoderMotor.cpp:530: undefined reference to `TwoWire::read()'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
Has anyone had any luck with using the DC encoder motors? I’ve gotten them to work as DC motors, but I want to control and read their positions for better control