View Single Post
  #6   Spotlight this post!  
Unread 23-01-2006, 02:03
CharlieWilken CharlieWilken is offline
Registered User
#0634 (Robowolves)
 
Join Date: Jan 2002
Location: Van Nuys, CA
Posts: 46
CharlieWilken is an unknown quantity at this point
Re: gyro and shooting angle

Tom-
with regards to your code:
int Step = 1; //Step is what step your shooter is at. 1 = 0 deg, 2 = 30 deg, 3 = 45 deg. Your robot starts with the shooter at step 1.
int WantedStep = 1; //Where You Want to Be
unsigned char ScaleFactor = 127;// How fast you want your motors to drive (127 = fastest, you'll see why.)

void ControlShooter(void){

if(Button1 == 1) WantedStep=1;
if(Button2 == 1) WantedStep=2;
if(Button3 == 1) WantedStep=3;
[b]
Motor = 127 + ( (WantedStep - Step) * ScaleFactor ); //Motor values hit max and min at 255 and 0

if(Switch1==1) Step=1;
if(Switch2==1) Step=2;
if(Switch3==1) Step=3;

See if Im doing this right:
from step two to wanted step 3 at full speed
Motor = 127 + (-1*127) = 0
that seems right
but from step 1 to 3
Motor = 127 +(-2*127) = -127
that doesn't seem right
or am I doing this wrong?