View Full Version : Help (Servo Control with IR Switch)

The Jackal
06-01-2005, 07:25 AM
I am trying to write a program to control two r/c servo's with an infrared switch. here is the program for the proximity sensor. when the sensor reads a certain number on the counter I want the servos to rotate in oposite directions. Any Help?'{ $STAMP BS2 }counter VAR NIBir_outputs VAR BYTEir_freq VAR WORDOUTPUT 7main: ir_outputs = 0 ' Load sensor outputs into l_ir_outputs and r_ir_outputs ' using a for...next loop, a lookup table, and bit addressing. FOR counter = 0 TO 4 LOOKUP counter, [37500,38250,39500,40500,41500], ir_freq FREQOUT 7, 1, ir_freq ir_outputs.LOWBIT(counter) = ~IN8 NEXT ' Display l_ir_outputs and r_ir_outputs in binary and ncd format. DEBUG home, "Readings from IR detector", cr DEBUG "Binary IR_outputs: ", bin5 ir_outputs, cr DEBUG "Object is in zone: ", dec5 NCD(ir_outputs)GOTO main

Post Edited By Moderator (Jon Williams (Parallax)) : 6/1/2005 12:44:57 AM GMT

06-02-2005, 02:38 AM
You may want to check out the "Robotics' " text and look at the infrared section in chapter 7, this will give you idea on how to develop the code. Here is a link for the "Robotics' " text download: http://www.parallax.com/detail.asp?product_id=28154


Dave Andreae

Tech Support
dandreae@parallax.com (mailto:dandreae@parallax.com)
www.parallax.com (http://www.parallax.com)