Is there a default code for the IR Sensor?
If so, can anyone give me a link or point me in the right direction?
If not, can anyone help me out with programming it? Me and my programming partners are new to the programming team so we hardly know anything about it.
Are you using MPLab?
Do you have it wired up correctly? It should end up going into 4 different digital ports. It sends a signal of 1 to them. Do you have it blinking the lights? There is a guide somewhere on here that tells how to do all of that. If you want I can send you the code I wrote for it as an example. I will try and find the link on here
Edit: Here is the link for the user guide for the sensor if you need that:
There is no default code for the sensor, but if you wire the four outputs on the IR board to four of the digital i/o pins, you can easily read the values it sends.
Include ifi_aliases.h and use the names it gives you for the digital inputs.
If you wired the board to the inputs 3-6, your code might look something like this:
#include "ifi_aliases.h"
char IR_in1 = rc_dig_in03;
char IR_in2 = rc_dig_in04;
char IR_in3 = rc_dig_in05;
char IR_in4 = rc_dig_in06;
How do you deal with the fact that the inputs are being pulsed on and off at around every 100ms? How does the program keep from repeating multiple times?
You may be interested in reading up on “switch debouncing”.
instead of having it do the actual actions when you press the button you can have it set a variable with the button, then it does a certain routine depending on the button pressed. Example:
unsigned char test;
if(rc_dig_in01)
test=1;
if(rc_dig_in02)
test=2;
if(rc_dig_in03)
test=3;
if(rc_dig_in04)
test=4;
if(test==1)
(routine a)
etc
We haven’t actually done anything with the physical IR Sensor, it’s just me and my programming partner are new to C and we need some tips on how to program it. We do have mplab.
Also if anyone can help with the yrg, the daa, and the gts, we would greatly appreciate it.
is that code adequte to adjust the variable “test”
One method is to create a timer loop that runs every 100 msec that read’s all four switches and saves the status. So, after 100 msec, the first thing inside the loop is to reset the timer to 0 and start again. Next, all four inputs are read and saved. 100 msec timer loop ends. Last, this routine can then be called whenever you want to determine the IR.
As long as 100 msec has expired since the last time you ran the loop, it should begin immediately.
here is a link to a copy of the code we wrote in easyc to test our ir board
each button on the remote should turn a different light on the operator interface on for 1 sec and then turn it back off.
hope this helps
http://whlspacedude.googlepages.com/IRBOARD.zip
also make sure you have the ir board hooked up right
here is some good info on hooking it up