Arduino Variables
Table of contents
Bits and Bytes
Humans usually think in decimal (base 10) values when counting.
Binary (base 2) values are at the core of all programming languages and hardware implementations.
- A bit is a binary digit, either a 1 or a 0 (zero).
- A byte is a group of 8 bits.
Integers
int
and long
An int
is an integer (usually) stored with 16 bits. The range of values stored in
a (16 bit) int
is -32768 to 32767.
A long
is an integer (usually) stored with 32 bits
Unsigned integer types
Integer arithmetic
Floating point
Floating point arithmetic
Lecture notes and exercises from ME 120
- Lecture slides in PDF start with
blink
and introduce variables - Detailed lecture notes on variable types
- Demonstration of integer types for counting time: or, Why you need to use
long
instead ofint
when storing output frommillis()
- Worksheet to compare variable types: Blank version (recommended for learning) and the completed version after you have studied with the blank version