Go to Post The true beauty is, no matter what the game (Yes, even 2001), we spend these 6 weeks going crazy with design strategy, and trying to figure out a way to work the plot twists that the GDC throws at us...and its a blast. - Andy Grady [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 25-01-2005, 00:07
Alex Wijtowych Alex Wijtowych is offline
Registered User
#1419
 
Join Date: Jan 2005
Location: Courtice, Ontario
Posts: 3
Alex Wijtowych is on a distinguished road
Array Problems: Possible<stdio.h>

Hello, I would appreciate if anyone can help me out with this arrray statement. I'm not sure if I have to put it in a function or import a header library so I can use an array. Here is my code, also it is available to anyone who wants to use it. It uses one joystick to drive a a 2 wheel drive bot with the wheels in the centre, like a tank. It also solves the problem of having the joystick go forward and the bot turn and vice versa.

/*Alex Wijtowych's Little addition to the code to make a dual axis drive system with a smoother control!!!*/
/*Let PWM 09 represent the right wheel of the bot and PWM 10 represent the left wheel of the bot*/
int speed_array[255] ={0,0,0,0,0,0,0,4,8,12,16,20,23,27,30,34,37,40,43, 45,
48,51,53,56,58,60,63,65,67,69,71,73,75,76,78,80,81 ,83,84,86,87,88,90,91,
92,93,94,96,97,98,99,100,100,101,102,103,104,105,1 05,106,107,107,108,
109,109,110,111,111,112,112,113,113,114,114,114,11 5,115,116,116,116,
117,117,117,118,118,118,119,119,119,119,120,120,12 0,120,121,121,121,
121,121,122,122,122,122,122,122,123,123,123,123,12 3,123,123,124,124,
124,124,124,127,127,127,127,127,127,127,127,127,12 7,127,127,127,127,
127,127,127,127,127,127,127,130,130,130,130,130,13 1,131,131,131,131,
131,131,132,132,132,132,132,132,133,133,133,133,13 3,134,134,134,134,
135,135,135,135,136,136,136,137,137,137,138,138,13 8,139,139,140,140,
140,141,141,142,142,143,143,144,145,145,146,147,14 7,148,149,149,150,
151,152,153,154,154,155,156,157,158,160,161,162,16 3,164,166,167,168,
170,171,173,174,176,178,179,181,183,185,187,189,19 1,194,196,198,201,
203,206,209,211,214,217,220,224,227,231,234,238,24 2,246,250,254,255,
255,255,255,255,255,255};
if (p1_y > 127 )
{
if (p1_x > 127)
{
pwm09 = speed_array[255 - (2 *(p1_x - 127))];
pwm10 = speed_array[p1_y];
}
else if (p1_x < 127)
{
pwm09 = speed_array[255 - p1_y];
pwm10 = speed_array[255 - (2 *(127 - p1_x))];
}
else if (p1_x == 127)
{
pwm09 = speed_array[p1_y - 127];
pwm10 = speed_array[p1_y];
}
}
else if (p1_y < 127)
{
if (p1_x > 127)
{
pwm09 = speed_array[255 - (2 *(p1_x - 127))];
pwm10 = speed_array[p1_y];
}
else if (p1_x < 127)
{
pwm09 = speed_array[255 - p1_y];
pwm10 = speed_array[2 *(127 - p1_x)];
}
else if (p1_x == 127)
{
pwm09 = speed_array[127 + (127 - p1_y)];
pwm10 = speed_array[p1_y];
}
}
else if (p1_y == 127)
{
if (p1_x < 127)
{
pwm09 = speed_array[127 + (127 - p1_x)];
pwm10 = speed_array[p1_x];
}
else if (p1_x > 127)
{
pwm09 = speed_array[127 - (p1_x - 127)];
pwm10 = speed_array[p1_x];
}
else if (p1_x == 127)
{
pwm09 = 127;
pwm10 = 127;
}
}

Last edited by Alex Wijtowych : 25-01-2005 at 00:22.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PC problems. . . opnickc IT / Communications 5 12-01-2005 16:53
Robot Rodeo - fixing control problems Gary Dillard Off-Season Events 7 26-10-2004 00:46
Do you all have problems with.... Munkaboo Website Design/Showcase 19 03-03-2003 19:51
Joystick problems archiver 2001 3 24-06-2002 02:40
Radio problems -- not archiver 2000 1 23-06-2002 22:23


All times are GMT -5. The time now is 23:10.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi