As i was testing nucleo64 in mbed notice that some arduino pin convention needs to be changed

for example, the pinMode in arduino need to be updated

pinMode(_pin1, OUTPUT)  ---> reconfigured as DigitalOut

i am wondering if there is any tutorial documentation that shows how to do conversion to MBED, listing every compatible command in arduino ide to what we have in MBED

 

Nonetheless, few days ago i tested with a MCU that uses the arduino IDE instead. Each of motor driver can be driven by a PWM pin and a directional pin. No grove shield is needed and this will save me one board

i want to verify that moving on grass has been resolved properly

 

My kid uploaded it at http://vt.tiktok.com/JLFovA/

 

so at least for sure now it is capable of running on its own on grass

 

to make it run, the arduino code is pretty simple

first put in the header file and define the pin in arduino ide style

 

#include "CytronMotorDriver.h"

// Configure the motor driver.
CytronMD motor1(PWM_DIR, 3, 4);   // PWM 1A = Pin 3, DIR=4 
CytronMD motor2(PWM_DIR, 5, 7); // PWM 2A = Pin 5, DIR=pin 7 

 

then, define the moving command, here moving forward is shown

 

void movefront()
{
  motor1.setSpeed(128);   // Motor 1 runs forward at 50% speed.
  motor2.setSpeed(128);  // Motor 2 runs forward at 50% speed.
  delay(1000);
  
  motor1.setSpeed(255);   // Motor 1 runs forward at full speed.
  motor2.setSpeed(255);  // Motor 2 runs forward at full speed.
  delay(10000);


  motor1.setSpeed(0);     // Motor 1 stops.
  motor2.setSpeed(0);     // Motor 2 stops.
  delay(5000);  
}

 

then we can just call it move forward or backward, example

// The loop routine runs over and over again forever.
void loop() {
movefront();
delay(2000);
movefront();
delay(2000);
moveback();
delay(2000);
moveback();
}