Getting DC motor to work


#1

I’m a teacher here at a high school in Ontario, Canada. We purchased a number of Ultimate MakeBlock robotic kits.
Right now I am just trying to get the micro-controller to spin the DC motor. Here is a link to a picture of the image.

Here is the source code I am using. It is from the MakeBlock examples.

#include “MeMegaPi.h”

MeMegaPiDCMotor motor1(PORT1A);

MeMegaPiDCMotor motor2(PORT1B);

MeMegaPiDCMotor motor3(PORT2A);

MeMegaPiDCMotor motor4(PORT2B);

uint8_t motorSpeed = 100;

void setup()
{
}

void loop()
{
motor1.run(motorSpeed); /* value: between -255 and 255. /
motor2.run(motorSpeed); /
value: between -255 and 255. */
motor3.run(motorSpeed);
motor4.run(motorSpeed);
delay(2000);
motor1.stop();
motor2.stop();
motor3.stop();
motor4.stop();
delay(100);
motor1.run(-motorSpeed);
motor2.run(-motorSpeed);
motor3.run(-motorSpeed);
motor4.run(-motorSpeed);
delay(2000);
motor1.stop();
motor2.stop();
motor3.stop();
motor4.stop();
delay(2000);
}

Can anyone suggest anything to try? We are at a loss at the moment.

My email is:

spuro.sourtzis@kpdsb.on.ca

thank you.

sourtzis


#2

Hi Sourtzis,

The motors on Ultimate 2.0 are encoder motors instead of DC motors.
You should use the wrong example code.


#3