Professional Documents
Culture Documents
Why do we program?
● Computers are very fast, but not very smart -- you have to tell them
exactly what to do
● It’s a good way to practice problem solving
● We want to build interesting things
Programming Languages
There are a ton of programming languages! Each of them has their own
benefits and capabilities.
C++ - Even faster! Can be complicated but can run on very small devices. This
is what we use for Arduino!
Programming for Arduino
The Arduino can take in voltage values from your circuit and process them in a
program. You might build a circuit that outputs a high voltage when an object
is close, or when you hit a button. You can then output a voltage based on the
inputs that you see.
Examples:
Notice that these lines end in a semicolon. This is true for almost every line in
C++, so don’t forget to put “;” at the end of each of your lines! Everything after
the “//” on each line is a comment, so the computer won’t try to read it.
Variables
Assigning variables gives a variable name an actual value with a single equals
sign “=”. You have to declare a variable before you can assign it. For example:
int x;
x = 3;
x = 4; // Variables can change values.
int y = 24; // You can declare and assign in the same line
Primitive Types
Name Description
Integer Holds a positive or negative number, but can’t have decimal points.
Float Just like an integer, but it can use decimal points too. It takes more memory.
Double Just like an integer, but it has the greatest range of values and can do math with
decimal points just like a float. It takes a lot of memory!
Short Just like an integer, but with a restricted range of values. It takes less memory.
Byte Just like an integer, but with a very restricted range of values. It takes very little
memory.
Long Just like an integer, but with a greater range of values. It takes more memory.
Primitive Types
Name Keyword Example Usage
Arrays are like lists of one type of data. For example, you could have an array
that holds the integers [2, -4, 124]. You can’t mix data types, so the array
[2, false, ‘c’] would not be possible.
Strings are arrays of characters; you can use this to spell out words. For an
example, the string “San Pedro” would be represented by the array