Sunday’s

Hummm… Arduino, motor shield to control CC motors, 4 motors, 4 wheels, battery and a RC radio… What could I do with that? =D

1

Bill of materials

Having all those components, thinking about putting them together and build something; it is not a big deal, but, it is always funny for Sunday.

Essentials,

Remote control

Hardware

Basically, connecting everything:

  • The CC motors in the motors from M1 to M4
  • The radio receiver could be fitted together in the servo signal (We need to read the PWM signal)
  • Lipo in the motor shield power

Et voilà!

2

4

Software

The full source code in my github

Motors

You could control directly the motors using PWM as in this link, https://www.dfrobot.com/wiki/index.php/Arduino_Motor_Shield_(L298N)_(SKU:DRI0009) ,

//Arduino PWM Speed Control:
int E1 = 5;
int M1 = 4;
int E2 = 6;
int M2 = 7;

void setup()
{
    pinMode(M1, OUTPUT);
    pinMode(M2, OUTPUT);
}

void loop()
{
  int value;
  for(value = 0 ; value <= 255; value+=5)
  {
    digitalWrite(M1,HIGH);
    digitalWrite(M2, HIGH);
    analogWrite(E1, value);   //PWM Speed Control
    analogWrite(E2, value);   //PWM Speed Control
    delay(30);
  }
}

Or using some library, as these from adafruit

Radio

The second thing to take into account is to read the signal from the radio receiver, a PWM signal, to Arduino. We could use this expression,

byte PWM_PIN = 3;

int pwm_value;

void setup() {page.youtubeTmr01v2_b %}
  pinMode(PWM_PIN, INPUT);
  Serial.begin(115200);
}

void loop() {
  pwm_value = pulseIn(PWM_PIN, HIGH);
  Serial.println(pwm_value);
}

Final results

The result,

3

And the video expected,