Constants

A constant is a value that never changes. In the Arduino programming language, we have two ways to declare constants. We can use the const keyword or the #define component.

The #define component enables us to give a name to a constant value prior to the application being compiled. The compiler will replace all references to these constants, with the assigned value, prior to the application being compiled. This means that the defined constants do not take up any program space in memory, which may be an advantage if you are trying to squeeze a large program into an Arduino Nano.

The #define component does have some drawbacks where the biggest drawback being if the name that is defined for the constant is also included in some other ...

Get Mastering Arduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.