Example 15‐RemoteControl of a motor with an App - GSTCH/SketchMadeEASY GitHub Wiki

The Sketch Made EASY classes support a RemoteControl App with the same functions as the FlySky FS-i6X (10-channel). Few more code is required to include these into a sketch.
If Sketch Made EASY is installed, it can be opened via menu: "File:/Example/SketchMadeEASY/Examples/15-MotorControlledByApp".

Schematic

App

Code

Adafruit MotorShield V2 at I2C‐Bus

#include <Easy.h>

//*****************************************************************
// Parameter Motor L298
#define MOTOR_SPEEDPIN 11
#define MOTOR_DIRECTIONPIN 12
// Parameter Motor L9110
#define MOTOR_PINA1 11
#define MOTOR_PINB1 12
#define MOTOR_PINA2 44
#define MOTOR_PINB2 46
// Parameter  I2C Motor
#define MOTOR_NUMBER 1
// Parameter for Bluetooth 
#define SOFTSERIAL_RXPIN 12
#define SOFTSERIAL_TXPIN 13

void setup()
{
  //((*** Initialize: Configure your sketch here....
  //** Create actuator:
  Actuator* motor = new MotorI2C(MOTOR_NUMBER);

  //** Define Input
  // RemoteControl, connected with bluetooth.
  RemoteControl* app = new AppInventor(scHard3);

  //** Define logic with condition and relation
  // No condition (NULL) because the relation is always active. 
  // With GetControl the AppInventor class creates the input control and returns its pointer. 
  Relation* relationFlySkyToMotor = new Relation1to1(NULL, motor, app->getControl(rcJoystick1Y));
  // ***))

  // Initialize control
  ControlManagerFactory::GetControlManager()->Setup();
}

//*****************************************************************
void loop() {
  //*** Run: No additional code is required
  ControlManagerFactory::GetControlManager()->Loop();

  // Depending on Arduino it needs a short delay. Do not add any other delays!
  delay(5);
}

L9110

Code only, look at previous examples 6-10 for schematic

#include <Easy.h>

//*****************************************************************
// Parameter Motor L298
#define MOTOR_SPEEDPIN 11
#define MOTOR_DIRECTIONPIN 12
// Parameter for Bluetooth 
#define SOFTSERIAL_RXPIN 12
#define SOFTSERIAL_TXPIN 13

void setup()
{
  //((*** Initialize: Configure your sketch here....
  //** Create actuator:
  // Different motor shields are supported, some are comment. Change comment and chose your motor shield.
  Actuator* motor = new MotorL9110(MOTOR_PINA1, MOTOR_PINB1);

  //** Define Input
  // RemoteControl, connected with bluetooth.
  RemoteControl* app = new AppInventor(scHard3);

  //** Define logic with condition and relation
  // No condition (NULL) because the relation is always active. 
  // With GetControl the AppInventor class creates the input control and returns its pointer. 
  Relation* relationFlySkyToMotor = new Relation1to1(NULL, motor, app->getControl(rcJoystick1Y));
  // ***))

  // Initialize control
  ControlManagerFactory::GetControlManager()->Setup();
}

//*****************************************************************
void loop() {
  //*** Run: No additional code is required
  ControlManagerFactory::GetControlManager()->Loop();

  // Depending on Arduino it needs a short delay. Do not add any other delays!
  delay(5);
}

L298

Code only, look at previous examples 6-10 for Schematic

#include <Easy.h>

//*****************************************************************
// Parameter Motor L298
#define MOTOR_SPEEDPIN 11
#define MOTOR_DIRECTIONPIN 12
// Parameter for Bluetooth 
#define SOFTSERIAL_RXPIN 12
#define SOFTSERIAL_TXPIN 13

void setup()
{
  //((*** Initialize: Configure your sketch here....
  //** Create actuator:
  // Different motor shields are supported, some are comment. Change comment and chose your motor shield.
  Actuator* motor = new MotorL298(MOTOR_DIRECTIONPIN, MOTOR_SPEEDPIN);

  //** Define Input
  // RemoteControl, connected with bluetooth.
  RemoteControl* app = new AppInventor(scHard3);

  //** Define logic with condition and relation
  // No condition (NULL) because the relation is always active. 
  // With GetControl the AppInventor class creates the input control and returns its pointer. 
  Relation* relationFlySkyToMotor = new Relation1to1(NULL, motor, app->getControl(rcJoystick1Y));
  // ***))

  // Initialize control
  ControlManagerFactory::GetControlManager()->Setup();
}

//*****************************************************************
void loop() {
  //*** Run: No additional code is required
  ControlManagerFactory::GetControlManager()->Loop();

  // Depending on Arduino it needs a short delay. Do not add any other delays!
  delay(5);
}
⚠️ **GitHub.com Fallback** ⚠️