Introduction: DIY Remote Controlled Arduino Motor Shield!

in this instructable you'll learn how to build an arduino dual-motor shield and how to decode an infrared remote and use it to control these motors.

Step 1: Parts and Assembly!

Parts:

- Arduino Uno

- L298 Motor Driver (x1)

- Veroboard (x1)

- Male or female Header Strip (enough to fit your arduino (32))

- 1N4007 Diodes (x8)

- 0.1uf and a 22uf capacitor

- Block connectors (x3)

- Jumper Wires

NOTE:

- E1-2 and E2-3 are connected to +5v they are enable pins so don't connect them to a block connector just to +5v in case we need to add a servo for steering we need enough pwm pins.

- for me i did not use the red ,green led's and 2.2 kohm resistor ,i counted on the Serial communication feedback that i have written.

assembly:

you could either etch a circuit board or just use jumper wires like i did .

i will not go through great details on how to solder the parts ,if you want follow my parts layout in the pictures above,

and solder the headers as shown in the figure that's the easiest way.

first cut them so they match your arduino pins,even if were not using all the pins on the arduino its better to fit headers on all of them so it would look nice and be more stable.

then place the headers like you would any component and solder from beneath.

.

L1 and L2 are connected to arduino pins 5 and 6 respectively which control motor (A) on pins 2,3 of l298 (forwards and backwards).

L3 and L4 are connected to arduino pins 9 and 10 respevtively .which control motor (B)on pins 13,14 of l298(forwards and backwards).

.

.

.

.

When your done with the hardware you can move on to the next step.

Step 2: Decode an IR Remote.

the only part you'll need for this step is an IR receiver .

you could either buy it or salvage it from and remote controlled device (tv,dvd ..etc).

pin1 of IR receiver goes to pin 11 of arduino , pin2 to ground ,pin 3 to +5v.

that's everything for the hardware ,now upload the attached file "IR-Decoder" to you arduino and open serial and make sure the baud rate is 9600.

now get a remote and start clicking you should start getting values on the screen.

you need 2 buttons for the forwards direction(increase and decrease speed), 2 buttons for the backwards direction(increase and decrease speed),and 1 button for stop.

you choose whatever buttons you need .

NOTE:Some of you may have noticed that if you press the same button for a long duration you'll get a different value which wont work in the code ,so you have to click the button gradually not continuously .

i found a lot of tv remotes that give you the same values while pressed for a long duration(example: sony),you just need to keep testing remotes.

the code will work fine even if you don't find one but its better and faster this way.

.

.IMPORTANT NOTE:

if you get an error while uploading the file just go to the directory of your arduino and remove \libraries\RobotIRremote\"IRremoteTools.cpp" and \libraries\RobotIRremote\"IRremoteTools.h"

.

now take note of these button values and move on to the next step .

Step 3: Updating and Uploading the Code.

now we're done with the IR-Decode file,we don't need it anymore,we only need the values that we noted.

now take these values and place them here but in the code(attached file):

#define upi 0x"value" ...(up increase)

#define upd 0x"value"... (up decrease)

#define Stop 0x"value" ...(stop)

#define downi 0x"value" ...(down increase)

#define downd 0x"value" ..(down decrease)

replace the ones in the quotes " replace" .

if your decoding and you get letters and numbers at the same time you have to place a 0x at the beginning,if you only have numbers don't place it.

so now connect everything up ,place the shield on the arduino solder the IR Reciever pins as described before on the shield,connect the usb ,upload only the motor-shield-dual-motor-variable-speed file which you modified.

and after uploading open Serial and check if your getting feedback and attach one motor at a time because the arduino alone cant handle two motors so it starts glitching.

after checking everything remove the usb cable connect an external power supply (12-18vdc)

and test both motors at the same time .

note:

if your motors arent rotating in the same direction and you dont want to flip the pins on the arduino or change the pins in the code just reverse the polarity of the motor

.IMPORTANT NOTE:
if you get an error while uploading the file just go to the directory of your arduino and remove \libraries\RobotIRremote\"IRremoteTools.cpp" and \libraries\RobotIRremote\"IRremoteTools.h" .

UPDATE:

i updated the code so that if your going forwards and u suddenly went backwards without stopping u'll momentarily stop and start reversing and no matter how many times you pressed forwards and backwards without stopping you'll start from initial value or speed 0.


and that's all folks!


hoped you enjoyed this instructable feel free to comment and FOLLOW!

happy instructables :)

Step 4: Update

if i get good feedback on this instructable i'll do a follow up instructable that features a self navigating rc car with diy IR proximity sensors, and i'll also share my arduino code and explain how to modify it if you want to add more sensors for better navigation.

Comments

author
diy_bloke made it!(author)2015-09-25

very interesting.
many remote controls send two codes though for the same key apparently to discriminate between long key presses and short key presses.
The disadvantage of that in your program is that one may need to press a specific key twice before it is recognised.
That ofcourse is easy to remedy by either defining two values for 1 key, or by masking if that is a possibility

As an example, my up value would be 0xE5139CA7 but also AC516266. Lets call these upd1 and upd2

your if statement could then be: if(results.value== upd1 || upd2){
The binary numbers are:
1110 0101 0001 0011 1001 1100 1010 0111
1010 1100 0101 0001 0110 0010 0110 0110
and in those i do not really see a mask that could be used but in other remotes it may

author
shaditheman123 made it!(author)2015-09-25

yeah that's what i said,but the problem is most remotes that give to two different values have the same second value for all the other buttons which causes a problem when there's "||".i didn't come by a remote that has two different values per button that's unlike the others so i might be mistaken.

but high end tv's have high quality remotes that give same value no matter what the button press duration is.

i'll test more remotes to c if i get this case.

but most probably i'll update my instructable and add some cases to the code like if each button has 2 values different from the others ,or 1 value different and the other alike ,and same distinct value for any press duration per button.

thanks for commenting,and for you advice,

and happy instructables :)

author
diy_bloke made it!(author)2015-09-26

I apologize, I may have missed that in your instructable.
the example that I gave was for the volume up and down and the channel up and down. (it is a universal remote programmed for Philips)
The number keys are quite predictable:
1 gives 1 on first press and 801 on second press

2 gives 2 on first press and 802 on second press
etcetera

for another Philips Remote I come to:

1->501/D01

2->502/D02
etc
As they both work on the same TV, I presume only the last 1 or 2 numbers are interpreted
I havent come across a remote yet that gives the same 2nd value for all keys :-)
I must say I have been impressed by your program. Reading and printing the key values in itself is not so difficult but to take actions on the keypresses requires a lot of nesting :-)
I need a lot of reading up before I know how to implement it in a 1600 line program your ibble was a great start. Thanks for that

author
shaditheman123 made it!(author)2015-09-26

haha no need to apologise man :p .
my main perpose for this instructable was to give the most basic code and for you to adapt on it and add some of your own things, so its like a cheat sheet for begginers ,and since i couldnt find any simple codes on the net i decided to start from scratch and i think i did a pretty good job at making it understandable.
so yeah a lot of things could be added like servos, sensors...etc,
its up to your imagination.
thanks for replying and liking my instructable.
and as always happy instructables :).

About This Instructable

6,112views

180favorites

License:

More by shaditheman123:DIY  remote controlled arduino motor shield!burning atmega328-pu and atmega328p-pu bootloader
Add instructable to: