Tuesday, August 12, 2008

[oopic] Need help--oIRRange Object

Hey, I try to use oIRRange Object(sharp GP2D12) to achieve obstacle avoidence.But it fails to read value from the sensor. I follow the oIRRange Object instruction and connect sensor to board. The code is blow. Please help me out. Thank you very much !
 

oServo S1 = New oServo;   // Make a servo object.
oServo S2 = New oServo;   // Make a servo object.

oByte x = New oByte;      // Make an 8-bit variable.

oIRRange I=New oIRRange;
oDIO8 P=New oDIO8;

Sub Void main(Void)
{
     S1 = 28;
     S2=28;
     x=1;
    
     I.IOLine=3;
     I.Operate=1;
     I.Adjust=8;
     P.IOGroup=1;
     P.Direction=cvOutput;
  Do
  {
     
     S1 = 20;
     S2 = 20;
     
     ooPIC.Delay = 50;
     S1= 40;
     S2=40;
      x++
     
     P.Value=I.Value;
    
     If(P>=64)                \\ I think there is something wrong at this place.
     {x=11;}
  } While (x<=10); 
        x=1;
 
  Do
  {
     ooPIC.Delay = 50;
     S1 = 40;
     S2=40;
    ooPIC.Delay = 50;
     S1 = 28;
     S2=28;
      x++    
  } While (x<=5);
}

Sub Void Setup(Void)
{
  //--Set up the first servo--
  S1.IOLine = 31;      //Set the servo to use I/O Line 31.
  S1.Center = 28;      //Set the servos center to 28. (see manual)
  S1.Operate = cvTrue;
  //--Set up the second servo--
 
  S2.IOLine = 30;      //Set the servo to use I/O Line 30.
  S2.Center = 28;      //Set the servos center to 28. (see manual)
  S2.Operate = cvTrue;   //Last thing to do, Turn the Servo on.
 }


[Non-text portions of this message have been removed]


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

No comments:

Post a Comment