Shop OBEX P1 Docs P2 Docs Learn Events
Help (Servo Control with IR Switch) — Parallax Forums

Help (Servo Control with IR Switch)

The JackalThe Jackal Posts: 1
edited 2005-06-01 19:38 in BASIC Stamp
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, [noparse][[/noparse]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

Comments

Sign In or Register to comment.