Notifications
Clear all
Search result for: WA 0812 2782 5310 [[PANDAWA]] Anggaran Dana Pengecatan Rumah Type 21 Lengkap Murah Magelang
Page 3 / 3
Prev
To put it simply, whenever the constant (SENSOR_PIN or LED_PIN) is called inside the program, the compiler replaces it with the defined constant value, i.e., A0 and 13, just like it does with global variables.
But unlike a variable, it assigns the value to all instances of the constant before the code is even compiled.
#define is a Type of preprocessor directive, meaning the compiler preprocesses it before compiling the code, thus taking up zero memory. The constant here is called the macro name (SENSOR_PIN or LED_PIN), and the value is called the macro value.
The reasons it's a better approach than simply using variables are:
They don't occupy any memory.
They improve code readability.
They can also be used with conditional directives (#ifdef, #ifndef, etc.) or functions to create code that behaves differently depending on certain conditions.
Hope this helps.
Page 3 / 3
Prev