Motor Control

Hello everyone,
I was wondering how to control a DC motor using the Arduino PINS. This part is very important, as my project is relying on PIN inputs to control it. You see, I am using the adafruit toggle type reciever: https://www.adafruit.com/products/1097, and the adafruit transmitter: https://www.adafruit.com/products/1095. Note: they are compatible, made by the same company, meant to work together, and worked together in tests.

(This is the receiver). What I need is a way to use this receiver to control whether the motor(dc) is on or off, by using pins. The receiver sends input to one pin, and when that pin recieves the input, it conrols another pin. I can do this with servos, but I don’t know how to do it with a motor. My code for the servo is here, to give you a sense of what is going on.

#include <Servo.h>

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13; // the number of the LED pin
Servo servo1;

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  servo1.attach (7);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {


    servo1.writeMicroseconds (2300);
  } else {
 
    servo1.writeMicroseconds (1000);
  }
}

I know this is a very long post. PLease let me know if you need more info. I have considered transistors, but I don’t know how I would configure the circuit. Thank you all for your help.

You will need some sort of motor driver to drive the motor as the Arduino can not supply the required current for a motor. Choose the motor driver based on the usage, rated voltage and stall current of the motor. By usage I mean, will the motor only turn in one direction? Will the speed of the motor need to be controlled? Only when the motor driver is known will we know how to interface to it.

I am sorry, I forgot to mention. I am using 3 AA batteries, and they do power the motor well. Am I not completely understanding you?

That receiver chip is available with two different types of outputs, one is a latched output and the other, like yours is a momentary output.

So it means, as the adafruit videos show, if you press the remote /arduino key, then the output goes on and stays on only as long as the key is pressed.

To make a motor run, you need something to boost the signal, typically a transistor or relay, but without knowing the exact type of motor, its voltage and current, cannot say which is needed.

Also if you want it to stay on after the key has been released, and needs a different key pressing to turn it off, then you need a Latching circuit on your recievers output as well.

So it means, as the adafruit videos show, if you press the remote /arduino key, then the output goes on and stays on only as long as the key is pressed.

I think you misunderstood. I bought the toggle type, which switches between off ad on with each button click. I just want to control if the motor is off or on, and which direction.

DC-Motors

WilkyRL:
I think you misunderstood. I bought the toggle type, which switches between off ad on with each button click. I just want to control if the motor is off or on, and which direction.

Forget about the motor for a while.

Just write a short program that gets data from the wireless and shows either "OFF" or "ON" the Serial Monitor.

If you have a problem with that, post the code for your best attempt.

When this works it will be easy to add on the motor control.

Is the motor you are using a servo, or perhaps an Electronic Speed Control that is controlled like a servo?

...R

Just write a short program that gets data from the wireless and shows either "OFF" or "ON" the Serial Monitor.

I have gotten the code to work fine on a servo motor. As I said, I am using a dc motor, which does not have the input wire (the yellow wire that receives the PIN signal; sorry, I forget what it is called.) A dc motor does not do that, and I need some way to tell the motor:
a)is it supposed to turn

b)how fast will it turn

The reciever, when it recieves the signal, sends that ONinput to the arduino PIN. I need some way
to push that input on the motor.

I am really sorry I have been unclear

Essentially, I want to control a DC like a servo.

This has all been very confusing. Because your pieces of code used the Servo library I assumed you were using a continuous rotation servo as the motor.

If you want to use a regular DC motor you need a motor-driver h-bridge. See, for example, the Pololu website. With that the speed is controlled using PWM with analogWrite().

Another option is to use an Electronic Speed Control (ESC). (See, for example, the HobbyKing website). Most of them are controlled like a servo.

...R