loading

Step 4: Circuit Diagram

The PICAXE basic code is easy: the main loop keeps looking for a signal from the IR receiver via the "irin" command. When it gets a code, it places in in variable b0. Then that variable is tested with a series of "if...then" statements. If the condition is true, a subroutine is evoked, then the program returns to the main loop.

;IR Receiver Test Circuit
;for PICAXE-18M2
;James Dinsmore 7/01/2011


init: servo 3,140 ; initialise servo
main:



irin [1000,main],B.2,b0 ;wait for new signal
;debug

if b0=16 then motorfwd
if b0=17 then motorbkwd
if b0=20 then stopmotor
if b0=21 then lightLED
if b0=24 then extinguishLED
if b0=19 then servoleft
if b0=18 then servoright
if b0=26 then servomiddle


goto main


;subroutines


motorfwd: high B.7
low B.6
goto main


motorbkwd: low B.7
high B.6
goto main


stopmotor: low B.7
low B.6
goto main


lightLED: high B.4
goto main


extinguishLED: low B.4
goto main


servoleft: servopos 3,200
goto main


servoright: servopos 3,80
goto main



servomiddle: servopos 3,140
goto main




Advertisement

<p></p><p>Other pins may be used for sensor input</p><p></p>
SALJUAREZ <br>HI. I&acute;M A 75 Y.O. NEW ELECTRONIC HOBBIST, I TRIED TO FOLLOW YOUR INSTRUCTIONS BUT I DON&acute;T GET ANY RESPONSE FROM THE R.C. ACTUALLY SOME TIMES THE LED FROM PIN 10 LITS BY ITSELF WITHOUT PRESSING ANY BUTTOM AND OTHER TIMS IT COMES ON ONLY BY TOUCHING ITS RESISTOR. <br>IS THERE A REASON FOR THIS???. <br>ALSO IS TEHERE ANY WAY OF TESTING IF THE MODULE IS RECEIVING ANY SIGNAL (RIGHT OR WRONG) FROM THE R.C.??? <br>I LIKE VERY MUCH YOUR INSTRUCTABLE IT IS VERY EXPLICIT, UNFORTUNATLY I&acute;M AFRAID I&acute;M DOING SOMETHIN WRONG. <br>I&acute;L APPRECIATE YOUR HELP.. <br>REGARDS. <br>
Whihc PICAXE chip are you using? (08M2, 18M2, etc.) What are you using to power your project? Is it a good, clean 3 to 5V? I have heard that the coding is different in Europe than in America; where are you geographically? You might try adding a few capacitors across your voltage supply to ground to take care of any stray noise that might be glitching the circuit. Try this code and watch the PICAXE monitor while pressing the remote's buttons:<br><br>;IR Receiver Test Circuit<br>;for PICAXE-18M2<br>;James Dinsmore 7/01/2011<br><br><br>init: servo 3,140 ; initialise servo<br>main:<br><br>irin [1000,main],B.2,b0 ;wait for new signal<br>;debug<br><br>if b0=16 then motorfwd<br>if b0=17 then motorbkwd<br>if b0=20 then stopmotor<br>if b0=21 then lightLED<br>if b0=24 then extinguishLED<br>if b0=19 then servoleft<br>if b0=18 then servoright<br>if b0=26 then servomiddle<br><br><br>goto main<br><br><br>;subroutines<br><br><br>motorfwd: high B.7<br> low B.6<br> goto main<br> <br> <br>motorbkwd: low B.7<br> high B.6<br> goto main<br> <br><br>stopmotor: low B.7<br> low B.6<br> goto main<br><br><br>lightLED: high B.4<br> goto main<br> <br><br>extinguishLED: low B.4<br> goto main<br> <br><br>servoleft: servopos 3,200<br> goto main<br> <br><br>servoright: servopos 3,80<br> goto main<br> <br> <br><br>servomiddle: servopos 3,140<br> goto main<br> <br><br><br>
HI. James i&acute;m sorry i did not answer you before. <br>I&acute;m in Mexico city, and i must tell you taht Ithe next day i sent my comment to you fixed a wron connection and it worked perfectly now I have the program and hardware working O.K. I tested it with leds and it works perfect, now what I can not do is have the motors work, I tried with an ULN 2803 IC but I dont get any response probably I&acute;m doing somethig wrong again, as I told you I&acute;m new at this, any how if you have any advise I will appreciate it.. <br>regards . <br>SAL.
is it possible to insert a 555 timer in the receiver circuit in order to control the robot or actuator from the sony remote control by a delay mechanism? So instead of the robot instantaneously responding to the sony remote control, it responds 10 seconds, 50 seconds or what ever amount of time you want it to respond.
I have been &quot;playing&quot; with PICAXE for about a year but I have never come across anyone who explains BASIC code and the IR function as clearly and succinctly as you have. I love all your projects ! <br>Thanks for sharing.
You are very welcome! Thank you for the encouragement. My most recent material resides on http://jmd.dev4.webenabled.net/<br>They have recently upgraded the PICAXE-18M2+ to include an internal temperature sensor; I am looking forward to playing with it soon.<br><br>James
sir, how did you make the PICAXE serial programming adapter and where did you get the software
Also, the SW is freely available from http://www.picaxe.com/Getting-Started/Software-Selection/<br>
<br>Page 44 of the Picaxe Manual 1 found at http://www.picaxe.com/Getting-Started/PICAXE-Manuals/ shows how to build the serial programming circuit. You can also purchase one from SparkFun at https://www.sparkfun.com/products/8313 . One catch is that newer computers may not have a D-9 serial port, in which case you woould have to get the more expensive USB programmer https://www.sparkfun.com/products/8312<br>James<br><br>http://www.picaxe.com/<br>
link error

About This Instructable

15,618views

10favorites

License:

Bio: Happily married man who loves life, nature and technology.
More by jamesthequack:Robot 3: Autonomous Sensor Platform 'Jimbo' IR Remote Controlled Tracked Robot IR Remote Control of PICAXE Micro 
Add instructable to: