Code arduino mcar 2 stepper and 1 servo


#1

Hi
I realized that I can’t send code to my MCAR with Mdraw, I must stay conected to my PC.
Have you an little Arduino code for MCAR has to make just rectangle?
I would like an example of a code for beginer
Think,
Sorry for my english


#2

Hi Cath_Heyman,

This is normal, the must be a connection between mDraw and mCar when you upgrade firmware for mCar or Draw a image with it.

For Guidance about how to use mCar, please download in this link: http://learn.makeblock.com/en/mdrawbot-kit/


#3

Hi Tec,
But we can not send the code in the memory of the MeOrion, from MDraw.exe, for MCAR is not connected to the PC?


#4

Hi Cath_Heyman,

mDrawbot doesn’t have this function.


#5

Hola, tengo el mismo problema ¿has conseguido que mCar funcione de manera autonoma? ¿tienes algun programa?

Gracias

==============

Hello, I have the same problem did you get to work autonomously mac? Do you have a program?
Thank you

jhilario


#6

Hello JHilario,
I make arduino code for make rectangle, in autonomously.
#include “MeOrion.h”
#include <SoftwareSerial.h>

MeStepper stepper1(PORT_1);
MeStepper stepper2(PORT_2);

// 1 tour =3200
// diametre roue =64 => Circ: 201.06
// entre axe roue = 130mm circ 130 = 408.4
// Longueur arc: 102.1 a 90° ( 408.4/360*90)
// 1 pas:201.06/3200=0.0628 mm
// nombre de pas pour 90° 102.1/0.0628=1625.82 pas

// variables
int turnSteps = -1630; // nombre de pas pour 90° 1616 91°
int lineSteps = -2500; //nombre de pas pour avanver
int stepperSpeed = 1000; //speed of the stepper (steps per second)
int steps1 = 0; // garder une trace du nombre de pas pour le moteur 1
int steps2 = 0; // garder une trace du nombre de pas pour le moteur 2
boolean turn1 = false; //trace si tourner ou avancer pour le moteur 1
boolean turn2 = false; //trace si tourner ou avancer pour le moteur 2

void setup()
{
delay(1000); //temps demarer robot apres alim
stepper1.setMaxSpeed(1000);
stepper1.setAcceleration(20000);
stepper1.move(1); // j’ai pas compris mais indispensable
stepper1.setSpeed(stepperSpeed);
stepper2.setMaxSpeed(1000);
stepper2.setAcceleration(20000);
stepper2.move(-1); // j’ai pas compris mais indispensable
stepper2.setSpeed(stepperSpeed);
}

void loop() {

if (steps1 == 0) {
int target = 0;
if (turn1 == true) {
target = turnSteps;
}

else {
  target = lineSteps;
}

stepper1.move(target);
stepper1.setSpeed(stepperSpeed);
turn1 = !turn1;

}

if (steps2 == 0) {
int target = 0;
if (turn2 == true) {
target = turnSteps;
}

else {
  target = -lineSteps;
}

stepper2.move(target);
stepper2.setSpeed(stepperSpeed);
turn2 = !turn2;

}

steps1 = stepper1.distanceToGo();
steps2 = stepper2.distanceToGo();

stepper1.runSpeedToPosition();
stepper2.runSpeedToPosition();
}


#7

Hello, thank you very much for the code, I’ll try it and if I can I will adapt. It looks very good.
So far I have gotten it to work autonomously using mDraw by the bluetooth module in the Port_5. Here you have a home video mCar and bluetooth
Thank you

===============
Hola, muchas gracias por el código, lo probaré y si puedo lo adaptaré. Parece muy bueno.
De momento he conseguido que funcione de manera autónoma usando mDraw mediante el módulo bluetooth en el Port_5.

Gracias


#8