You are on page 1of 1

CPE 322 – Arduino IDE and Code

There are two buttons in the IDE section which we


The Arduino IDE (Integrated Development Environment)
need to keep in mind when we are ready to upload
is used to write the computer code and upload this code
our code:
to the physical board.
 Verify – Checks your code for errors
Parts of the Arduino IDE:  Upload – Uploads your code to the Arduino

The elements of an Arduino C++ Code

The setup() function is called when a sketch starts.


Use it to initialize variables, pin modes, start using
libraries, etc. The setup() function will only run
once, after each powerup or reset of the Arduino
board.

The loop() function does precisely what its name


suggests, and loops consecutively, allowing your
program to change and respond.

The digitalRead() function reads the value from a


specified digital pin, either HIGH or LOW.
The digitalWrite() function writes a HIGH or a LOW
value to a digital pin.
The pinMode() function configures the specified
pin to behave either as an input or an output.
The analogRead() function reads the value from
the specified analog pin. Arduino boards contain a
multichannel, 10-bit analog to digital converter.
This means that it will map input voltages between
0 and the operating voltage(5V or 3.3V) into
integer values between 0 and 1023.
The analogWrite() function writes an analog value
These buttons allow you to quickly access the (PWM wave) to a pin. Can be used to light a LED at
actions that you will perform most often with the varying brightnesses or drive a motor at various
code window. These actions include checking if speeds.
your code has any errors (verifying), sending your
code to the Arduino board (uploading), creating a The delay() function pauses the program for the
new file, opening a file and saving it. amount of time (in milliseconds) specified as
parameter. (There are 1000 milliseconds in a
Every program you upload to your Arduino is second.)
considered a “sketch.” The name of the sketch
appears in a tab in the upper left hand corner of
the code editor.

You might also like