Hello,
I’m a French student in High School, and I have some problems with the libraries of Makeblock.
I need to make the plotter table move in two axis X and Y.
So I used the example of the "SerialControlStepper"
This is the code :
#include <AccelStepper.h>
#include <Makeblock.h>
#include <SoftwareSerial.h>
#include <Wire.h>
int dirPin = mePort[PORT_1].s1;//the direction pin connect to Base Board PORT1 SLOT1
int stpPin = mePort[PORT_1].s2;//the Step pin connect to Base Board PORT1 SLOT2
AccelStepper stepper(AccelStepper::DRIVER,stpPin,dirPin);
int dirPin2 = mePort[PORT_2].s1;//the direction pin connect to Base Board PORT1 SLOT1
int stpPin2 = mePort[PORT_2].s2;//the Step pin connect to Base Board PORT1 SLOT2
AccelStepper stepper2(AccelStepper::DRIVER,stpPin2,dirPin2);
void setup()
{
Serial.begin(9600);
// Change these to suit your stepper if you want
stepper.setMaxSpeed(100000);
stepper.setAcceleration(200000);
stepper2.setMaxSpeed(100000);
stepper2.setAcceleration(200000);
}
void loop()
{
if(Serial.available())
{
char a = Serial.read();
switch(a)
{
case ‘0’:
stepper.moveTo(0);
break;
case ‘1’:
stepper.moveTo(12500);
break;
case ‘2’:
stepper.move(12500);
break;
case ‘3’:
stepper2.move(12500);
break;
case ‘4’:
stepper.move(-12500);
break;
case ‘5’:
stepper.move(-12500);
break;
case ‘6’:
stepper2.move(12500);
break;
case ‘7’:
stepper.move(12500);
break;
case ‘8’:
stepper.move(12500);
break;
case ‘10’:
stepper.move(-25000);
stepper2.move(-24500);
break;
case ‘9’:
stepper.moveTo(12500);
delay(100);
stepper.move(12500);
delay(100);
stepper2.move(12500);
delay(100);
stepper.move(-12500);
delay(100);
stepper.move(-12500);
delay(100);
stepper2.move(12500);
delay(100);
stepper.move(12500);
delay(500);
stepper.move(-25000);
stepper2.move(-24500);
break;
}
}
stepper.run();
stepper2.run();
}
I want to understand more…
I want to mix the two exemples to make the table move and when the limit switch is touched, the table must to stopped.
And I want the table will do the path automatically without using the “case”. Just start the program and it will do the scanning in the work area of the table.
If you want some informations to my part of my project or of my program ask it.
I need some informations and some help to your part if it’s possible.
Thanks,
Yasmina