O'Reilly logo

Mastering Arduino by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required