View Single Post
  #10   Spotlight this post!  
Unread 06-08-2010, 17:34
siaohuang siaohuang is offline
Registered User
no team
 
Join Date: Aug 2010
Location: Fort Wayne IN
Posts: 10
siaohuang is an unknown quantity at this point
Re: Delay10KTCYx in C18

Thank you guys so much! I have it working!! After reading I did some adjustments and it worked just as I wanted: When the button is pressed the robot will reverse and make a turn and go straight. Here is my code for that!

Code:
static int counter2=0;
static int counter3=0;
static int signal=1;
static int trigger=0;

pwm02=100;
pwm03=155;

signal=Get_Analog_Value(rc_ana_in02);

if (signal==0){
  trigger=1;
}

if(trigger==1){
   pwm02=155;
   pwm03=100;
counter2=++counter2;   
 if (counter2>109){
         pwm02=155;
         pwm03=155; 
      counter3=++counter3;
      if (counter3>109){
           pwm02=155;
           pwm03=100;
           trigger=0;
           counter2=0;
           counter3=0;
     }	
  }  
}
To Foster I forgot to mention that in the Vex instruction manual says that the buttons are digital sensors, which sends a voltage, but instead of sending a voltage between zero and max, it will send only zero or maximum.And the Signal pin is HIGH when the switch is open, Pushing Switch brings the signalpin voltage to LOW. I wish I can show you guys what I've done, thank you so much, I will move on to the next chapter the light sensors!