View Single Post
Old 10-11-2011, 05:33 PM
jpearman's Avatar
jpearman jpearman is offline
Senior Member
VEX # 8888
Join Date: Apr 2011
Location: Los Angeles
Posts: 3,970
Re: RobotC programming tips

Some of the uses for the #define statement, not all necessarily good programming but it shows that it has other uses beyond just defining constants. More explanation here

#pragma config(UART_Usage, UART1, VEX_2x16_LCD, baudRate19200, IOPins, None, None)
#pragma config(Motor,  port1,           ,              tmotorNormal, openLoop)
#pragma config(Motor,  port2,           ,              tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#define DEBUG

#define ABS(x)          ( (x)>=0?(x):-(x) )

#define DRIVE_MOTOR(x)  do{\
                        motor[port1] = (x);\
                        motor[port2] = (x);\

#define JOY_DRIVE       vexJSLeftV

#define DISPLAY_MOTORS  do{\
                        displayLCDNumber(1, 0, motor[port1], 3);\
                        displayLCDNumber(1, 8, motor[port2], 3);\

task main()
      DRIVE_MOTOR( vexRT[ JOY_DRIVE ] ); 

#ifdef  DEBUG
Reply With Quote