Programming: #define Statement Explained
Share
The #define statement is a macro. The #define statement can be use to substitute a name for a number. It can also be used to change the name of another definition. Example: #define MrLCDsCrib PORTB This makes MrLCDsCrib defined as PORTB, so MrLCDsCrib can be used wherever PORTB is used. The #define also makes it convenient to change values whenever the need arises. Say, for instance, MrLCDsCrib was plugged into PORTA instead. Then only one statement would need to be changed rather than having to go throughout the program changing all of the PORTBs to PORTAs. The #define can also be used to name numbers: I generally only use #define statement for things that may change. Every time you need to reference pin 5, LCDEnable can be used for this purpose.
#define LCDEnable 5