|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
|
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 |