C Programming For FIRST FRC Competitions
Source: www.intelitekdownloads.com
Topic: C Programming
Short Desciption:... the Robot Controller and the Operator Interface. http://www.chiefdelphi.com A forum for FIRST teams to discuss all aspects of FIRST. Use your favorite search engine to look up C Programming, or C Tutorial ...
Content Inside:
1/8 2007
C Programming
For
FIRST
FRC
Competitions
Keith M. Hughes
1/8 2007
easyC Pro come with lots of examples and tutorials. Look at them with
copies of these slides by your side and you will see how it all fits
together.
DONT PANIC!
1/8 2007
Programming. Who Needs It?
Every team will most likely need some programming. It is necessary to connect
the controls on the Operator Interface to the motors, relays, etc, on the
robot.
Autonomous mode requires the most programming, though it doesnt necessarily
have to be that sophisticated.
1/8 2007
Warning
Dont wait on understanding the programming or thinking about it until towards
the end of the build season. The programmers need to be involved early on
with the planning for hardware since they have to write programs for the
sensors, because they have to think about what can and cannot be done in
software.
This means the programmers need to understand programming sooner than
later.
1/8 2007
What Well Cover
The basics of the C programming language.
I am not telling you everything as I am trying to keep this a short
introduction. Experienced C programmers will notice that some things I am
saying have to happen dont always have to, but it takes too long to explain
everything.
1/8 2007
Variables
Variables are named bits of memory in the processor. You use variables to
keep bits of computations that you have done or to control the robot.
pwm1 = p1_x;
pwm2 = 255 - p1_y;
speedLeftMotor = GetAnalogValue (3) * 2;
speedRightMotor = speedLeftMotor / 2;
The variables above are pwm1, p1_x, pwm2, p1_y, speedLeftMotor, and
speedRightMotor.
1/8 2007
Variables
Variables in C must be given a type. The type says what kind of information
can be stored in the variable.
The type for a variable is given in a variable declaration.
unsigned char speedLeftMotor;
int leftWheelCounts;
The underlined parts are the type of the variabl ...

