Society of Robots - Robot Forum
Software => Software => Topic started by: jessman275 on September 28, 2009, 06:56:07 PM
-
So I purchased a Axon controller and started messing around with it. So far its works great. I have looked around on the forums and have yet to find a topic about IR sensors and how they could control a motor or Solenoid. I have tried to program the controller by modifying some existing code and needless to say it didn't work. I have purchased a IR sensors listed below
http://www.acroname.com/robotics/parts/R185-SINGLE-LINE-IR.html (http://www.acroname.com/robotics/parts/R185-SINGLE-LINE-IR.html)
I have used this type of sensor for data logging on cars before and had a great experience with it.
I would like to have the IR sensor pick up off a rotating object and activate a solenoid every time the white line comes around. I am very new to programming and have read many tutorials, but still haven't gotten the hang of it.
My Pseudo code looks like this
"
read IR sensor PORT,F1
if IR sensor detects line
then activate relay on PORT E2 for 30ms
"
Can someone lead me in the right direction on how to solve this problem. If there is a tutorial out there that is similar to this that would help tremendously.
Thanks
Jesse
-
Your pseudocode gets you 90% there.
read IR sensor PORT,F1
becomes:
value=a2dConvert8bit(0);
read this:
http://www.societyofrobots.com/axon/axon_function_list.shtml#adc (http://www.societyofrobots.com/axon/axon_function_list.shtml#adc)
if IR sensor detects line
if(value > 128)
then activate relay on PORT E2 for 30ms
read this:
http://www.societyofrobots.com/axon/axon_function_list.shtml#digital_output (http://www.societyofrobots.com/axon/axon_function_list.shtml#digital_output)
you'll also need a MOSFET to drive your relay
you'll also need this to turn off the relay:
else
PORT_OFF(PORTA,6);
so summing it up:
while(1)
{
value=a2dConvert8bit(0);
if(value > 128)//depends on values you expect
PORT_ON(PORTA,6);
else
PORT_OFF(PORTA,6);
delay_ms(10);//prevent crazy fast oscillation
}