|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
White Paper Discuss: C Programming and Autonomous Modes for Newbies
Thread created automatically to discuss a document in the White Papers.
C Programming and Autonomous Modes for Newbies by cbolin |
|
#2
|
|||||
|
|||||
|
Re: White Paper Discuss: C Programming and Autonomous Modes for Newbies
Congratulations, Chuck--I guess it takes a South Carolinian to speak to a South Carolinian. This is the first programming white paper that actually clicked with me. (I'm not a programmer by any stretch. But I guess that's obvious).
One question, on the line tracking example in the autonomous notes...at Position D, when the left sensor is made, shouldn't the robot turn to the left instead of the right? But other than that, bravo! |
|
#3
|
|||||
|
|||||
|
Re: White Paper Discuss: C Programming and Autonomous Modes for Newbies
I read this yesterday morning. I thought it was great also. I sent him a PM with my thanks.
I didn't notice this error yesterday but now reading it again I do see it. It seems like he messed up that whole section. Here is what I think It should look like: Code:
//place this line before while (autonomous_mode).
unsigned char s_left = rc_dig_in01;
unsigned char s_middle = rc_dig_in02;
unsigned char s_right = rc_dig_in03;
//place this after Getdata(&rxdata);
if (s_left == 0 && s_middle == 1 && s_right == 0)
// Middle sensor on
// Go straight
{
pwm01=160; //left motor
pwm02=160; //right motor
}
else if (s_left == 1 && s_middle == 1 && s_right == 0)
// Left 2 sensors on
// Turn soft Left
{
pwm01=127; //left motor
pwm02=160; //right motor
}
else if (s_left == 1 && s_middle == 0 && s_right == 0)
// Left sensor on
// Turn Hard Left
{
pwm01=127; //left motor
pwm02=180; //right motor
}
else if (s_left == 0 && s_middle == 1 && s_right == 1)
// Right 2 sensors on
// Turn soft right
{
pwm01=160; //left motor
pwm02=127; //right motor
}
else if (s_left == 0 && s_middle == 0 && s_right == 1)
// Right Sensor on
// Turn Hard Right
{
pwm01=180; //left motor
pwm02=127; //right motor
}
else //stop
{
pwm01=127; //left motor
pwm02=127; //right motor
}
Again, Great Job Chuck Last edited by Gamer930 : 20-12-2004 at 07:22. Reason: Tried to fix indenting on code |
|
#4
|
||||
|
||||
|
Re: White Paper Discuss: C Programming and Autonomous Modes for Newbies
I am a newbie; this is my first year in FRC. I know how to program in many other languages, but C is a new one for me. If anyone has any tips or advice on programming for a newbie, I'd be much obliged.
All I have to learn it at home is a college textbook...I'm a freshmen in High School! Anyway, any help would be greatly appreciated. Thanks! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Autonomous Programming Guide | cbolin | Programming | 2 | 16-12-2004 15:13 |
| Autonomous Programming Competition Signup List | SilverStar | Programming | 36 | 13-05-2004 15:09 |
| Programming Autonomous mode | Jared Stofflett | Programming | 3 | 11-11-2003 09:32 |
| autonomous sensor programming ? | Laura_d | Programming | 1 | 10-02-2003 17:46 |
| How do you do the autonomous programming? | Ryan Collings | Programming | 11 | 07-02-2003 19:38 |