Professional Documents
Culture Documents
Session 4: Arduino
Software
Before Starting
With
ARDUINO
Electronic Cautions
Two sources of power
Connection at the first
No resistors for LEDs
Multiple grounds
Close soldering iron
Short circuit
Arduino Programing is one
of the International
Language Codes Most used
Worldwide!
Now!
Before anything, you need to download the
Arduino Program. So to do that,
you can go to:
http://www.arduino.cc/en/software
And you can install it easily!
After installing the program,
let’s try and open it.
Function Function
It is mandatory It is mandatory
pinMode(pin, mode)
digitalWrite!
digitalWrite!
‘0’ or ‘1’
LOW or HIGH
OUTPUT
digitalWrite!
digitalWrite(pin, value) is a command written in ‘loop()’
‘pin’: stands for the pin whose mode you wish to set
‘value’: stands for High (‘1’) or Low(‘0’)
For a LED, High means
to turn it On while Low
means to turn it Off.
Only W is Pin Number All Letters
capitalized Capitalized
NEVER
FORGET that after
each command we
should have a semi
colon!! « ; »
Another function we use in «loop()» ?
digitalRead!
digitalRead!
‘0’ or ‘1’
LOW or HIGH
INPUT
digitalRead!
‘digitalRead(pin)’ is a command written in ‘loop()’.
It reads the value from a specified digital pin,
either HIGH or LOW.
Digital
Output Input
Now, Let’s try the example ‘Blink’!
ARDUINO IDE
Then on top of the
Program,
tap on ‘File’.
In the examples,
you can find the
code
of example
‘Blink’.
Verify
The code of
‘Blink’ will open
up
After the ‘Verify’, there might be
an error in the code or no error
Now let’s connect the
Arduino Uno
to the Laptop!
To make sure that the
Arduino Uno is
connected to the
laptop, on the top of
the program, press on
‘Tools’ and check the
‘Board’ and ‘Port’ as
shown.
Now, after
making
sure that
everything
is well done,
press on
‘Upload’
Check the Result
on your
Arduino Uno!
LED
EVERYTHING
IS
FINE
Example: let’s try to make a LED turn ON
First, the LED has a polarity!
The longer leg is to be
connected to the pin(+) _ +
While the shorter leg needs
to be connected to the
ground(-)
Otherwise, it won’t turn On!
CODING
SAVE YOUR CODE
How to save your work?
1-First, go to your
desktop.
Press right click
then create a ‘new
folder’.
2- Name it ‘Arduino Examples’
variable!
Name Type
Value
For example, this statement creates a variable
int pin = 13;
Everything written after ‘//’
are comments. Comments are
Type lines in the program that are
(int = integer) Name Value used to inform yourself or
others about the way the
program works. They are
ignored by the compiler
We write the declaration of
variable before the
setup()!
Connectthe LED
to pin 13 to see the result!
Evaluation Time!
Pin
number 8
SEE YOU NEXT WEEK