Introduction: 3 Steps Easy On/Off Remote Control With Arduino

Based on other project found on internet, I decided to make my own remote controlled Arduino circuit.

I needed two 5V motors to be switched On and Off with an remote. As a result I've got the project below.

You can modify your project any way you want. For example you can change polarity of one motor and it will turn opposite direction comparing to another one. Or you can add a servo motor instead of dc motor.

There are so many possibilities. Make your own and share with community.

Step 1: Parts Required

- Arduino

- 2 x 5V motors (if you like to use other type of motors you will need drivers for them)

- IR receiver (I used one from old dvd player)

- jumper wires male + female (make your own like this. )

- any remote control

Step 2: Assembly

- connect IR receiver left pin to pin 11, middle pin to GND and right pin to 5V on Arduino board

- connect motor 1 to Arduino pin 3 and GND pin

- connect motor 2 to Arduino pin 4 and GND pin

* you can use any pins you like but you have to change pin numbers inside code

Step 3: The Code

/*

source: The mighty Internet

You'll need to change the led pins and the codes accordingly to your configuration and IR remote

*/

#include int RECV_PIN = 1;

// the pin where you connect the output pin IR receiver int motor1 = 3;

int motor2 = 4;

int itsONmotor[] = {0,0,0,0};

/* the initial state of motor is OFF (zero) the first zero must remain zero but you can change the others to 1's if you want a certain motor to run when the board is powered

*/

#define code1 63495 // code received from button A (change with your remote code)

#define code2 30855 // code received from button B (change with your remote code)

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {

Serial.begin(9600); // you can comment this line

irrecv.enableIRIn(); // Start the receiver

pinMode(motor1, OUTPUT);

pinMode(motor2, OUTPUT); }

void loop() {

if (irrecv.decode(&results)) {

unsigned int value = results.value;

switch(value) {

case code1:

if(itsONmotor[1] == 1) {

digitalWrite(motor1, LOW); // turn it off when button is pressed

itsONmotor[1] = 0; // and set its state as off }

else { // else if first led is off

digitalWrite(motor1, HIGH); // turn it on when the button is pressed

itsONmotor[1] = 1; // and set its state as on }

break;

case code2:

if(itsONmotor[2] == 1) {

digitalWrite(motor2, LOW);

itsONmotor[2] = 0; }

else {

digitalWrite(motor2, HIGH);

itsONmotor[2] = 1; }

break; }

Serial.println(value); // you can comment this line

irrecv.resume(); // Receive the next value }

}

/ * after uploading the code, open Serial monitor, press the button on your remote and the code you see on monitor

you have to write on #define code1 ... ; same for second motor

*/

Comments

author
russ_hensel (author)2016-02-17

To make your code more readable, Put Your Code In A Box, Properly Indented, on Instructables : https://www.instructables.com/id/Put-Your-Code-in-a...

It is not too late to edit the instructable.

About This Instructable

1,060views

18favorites

License:

Bio: In a continuous learning process.
More by AnsoGroup:3 easy steps to make a voltage divider3 steps easy On/Off remote control with Arduino3 Steps to Remove Wax From Clothes
Add instructable to: