HELP! Me Uno Shield -stepper motor can not be used with port 2


#1

I would like to use MeUnoShield and 3 stepping motors.
However, stepping motor can not be used at port 2.

This is the Arduino code

#include “MeOrion.h”
#include <SoftwareSerial.h>

MeStepper stepper(PORT_1);
MeStepper stepper2(PORT_2);

void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(1000);
stepper.setAcceleration(20000);
stepper2.setMaxSpeed(1000);
stepper2.setAcceleration(20000);
}
void loop()
{
if(Serial.available())
{
char a = Serial.read();
switch(a)
{
case ‘0’:
stepper.moveTo(0);
stepper2.moveTo(0);
break;
case ‘1’:
stepper.moveTo(200);
stepper2.moveTo(200);
break;
case ‘2’:
stepper.move(50);
stepper2.move(50);
break;
case ‘3’:
stepper.move(100);
stepper2.move(100);
break;
case ‘4’:
stepper.move(200);
stepper2.move(200);
break;
}
}
stepper.run();
stepper2.run();
}

Port 1 could be used.

What should I do?


#2

Once I copy the code and try to upload, I got some error message.
image
Then I tried to edit MakeblockDrive->MeStepperMotor->SerialControlStepper, like below:
#include “MeOrion.h”
#include <SoftwareSerial.h>

MeStepper stepper(PORT_1);
MeStepper stepper2(PORT_2);

void setup()
{
Serial.begin(9600);
// Change these to suit your stepper if you want
stepper.setMaxSpeed(1000);
stepper.setAcceleration(20000);
stepper2.setMaxSpeed(1000);
stepper2.setAcceleration(20000);
}

void loop()
{
if(Serial.available())
{
char a = Serial.read();
switch(a)
{
case ‘0’:
stepper.moveTo(0);
stepper2.moveTo(0);
break;
case ‘1’:
stepper.moveTo(2000);
stepper2.moveTo(2000);
break;
case ‘2’:
stepper.move(5000);
stepper2.move(5000);
break;
case ‘3’:
stepper.move(8000);
stepper2.move(8000);
break;
}
}
stepper.run();
stepper2.run();
}

Please remember to use the 12V DC power supply in case insufficient power.
And if your board is me uno shield, you have to change the “MeOrion.h” to “MeShield.h”.


#3

I solved this problem easily.

#include “MeOrion.h” --> #include “MeShield.h”

The port position seems to be different in Me Orion and Me Shield.

MeOrion.h
/********************* Orion Board GPIO Map *********************************/
// struct defined in MePort.h
MePort_Sig mePort[17] =
{
{ NC, NC }, { 11, 10 }, { 3, 9 }, { 12, 13 }, { 8, 2 },
{ NC, NC }, { A2, A3 }, { A6, A1 }, { A7, A0 }, { 6, 7 },
{ 5, 4 }, { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC },
{ NC, NC },{ NC, NC },
};

MeShield.h
/********************* Shield Board GPIO Map *********************************/
MePort_Sig mePort[17] =
{
{ NC, NC }, { 11, 10 }, { 9, 12 }, { 13, 8 }, { NC, 3 },
{ NC, NC }, { NC, 2 }, { A2, A3 }, { A0, A1 }, { 5, 4 },
{ 6, 7 }, { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC },
{ NC, NC }, { NC, NC },
};


#4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.