KEMBAR78
Starting with Arduino | PDF
‫إعداد‬:‫شماسنة‬ ‫مجدي‬‫لعام‬ ‫والبرمجة‬ ‫األردوينو‬ ‫لدورة‬ ‫خصيصا‬ ‫األوراق‬ ‫هذه‬ ‫عدت‬ُ‫أ‬2017‫لنادي‬Imech E‫بيرزيت‬ ‫جامعة‬ ‫فرع‬
The contents of this Course :
This course is a workshop ( no much of Theories ) , so will involve in :
1. Identify the ARDUINO board parts and their works / power suppling methods / output and input pins .
2. Identify the Basic programming functions ( reading inputs and returning Outputs )
3. Identify the signals types that the ARDUINO treat with
4. Using sensors : a. measuring the room temp
b. measuring the light intensity
c. detection the movement .
d. Making a distance measuring tool ( using ultrasonic sensor )
e . --- working on a new sensor individuality ---
6. Using motors : a . DC motor
b. servo motor
c. stepper motor
5. Identify the H-BRIDGE and its usage
7. Using the KeyPad
8. Identify Serial interface
9. Using LCD display.
10 . -- Task : making a personal messenger --
11. Using a inferred IR sensor with remote Control
12 . use a seven segment screen
*** if there enough time , we will Do a PID
Control by ARDUINO ☺
Arduino : is a MICROCONTROLLER , able to be programmed by the users via ( Arduino c programming) .
( in fact , it is a Tiny computer )
MICROCONTROLLER : integrated circuit (fig 1.1) , contain CPU , memory ( RAM, ROM, Flash) ,
inputs & outputs ports
Fig 1.1 : Integrated circuits
Arduino Uno
Arduino Leonardo
Arduino Mega
Arduino LilyPad
Arduino Nano
Arduino mini
Cortino (ARM)
LeafLabs Maple
3
1
1. USB cable
2. External power supply
3. ATMEGA328 microcontroller
4. USB to Serial controller
5. 5V regulator
6. 16 MHz crystal
7. Rest push Potton
8. Ground (GND)
9. ( 5 ) volt output power
10. ( 3.3 ) output power
11. Input power pin
12. Analog input pins
13. Analog output pins ( ~3,~5,~6,~9,~10,~11)
14. Digital output / input pins ( All pins)
15. TX,RX led
16. Led connected with pin 13
17. Power indicator
2
3
4
5
6
7
8910 11
12
131415
16
17
Rated Power ( 7-12 ) volt
This done By :
1. Power Jet ( Battery )
1. Another circuit
1. USB cable
1
2
3
1
2
3
Vin
Digital Signal : Is a signal consists from tow values ( 0 or 1 )
To read a digital signal use the function : digitalRead();
To write a digital signal use the function : digitalWrite ();
In Arduino :
(logic 0) = ( volts 0) = LOW = OFF
( logic 1) = (volts 5) = HIGH = ON
Digital signals received and send by using the 14 pins
1 give a name for the pin “Optional”
1
2 Open the pin mode as ( INPUT / OUTPUT)
2
3 The pin is ready to Use by its name or
By its number
Analog Signal : Is a sinusoidal signal
To read an Analog signal use the function : analoglRead();
To write a digital signal use the function : analogWrite ();
Analog signals received by using the (A0 …. A5) pins
Analog signals sent by using the (~3 , ~5, ~6, ~9 ,~10, ~11) pins
Arduino treat with this type of signals as a ( 8 bit digital data )
(0 – 5 volt)  (0 – 255)
1 give a name for the pin “Optional”
2 Open the pin mode as
( INPUT / OUTPUT)
3 The pin is ready to Use by
its name or By its number
1
2
3
1 Lab View Interfacing
2 Mathlab Interfacing
3 Arduino IDE
IDE : Integrated Development Environment
Free program , you can get it from :
https://www.arduino.cc/download_handler.php
1 Verify : to check the code and catch the syntax Errors
5 Upload : to Save your Work on Your Computer
3 New : to Open New Sketch
4 Upload : to Open a Existence Sketch (Saved on
Computer Before )
2 Upload : to upload the code on the Arduino chip
6 Serial Monitor : to Open The Serial Monitor (
an Interfacing Monitor )
7 Sketch Name : Shows the Name of Current
Sketch
8 Coad Area : Coding Area
9 Massage Area : Show the Errors after Compile
10 Text Console : Show a full Error Massage
11 Board and Serial Port : Arduino COM number
1 Choose Your Arduino Type ::
Tools  Board  “ Select yours Board “
Most common boards :
1. Arduino /Genuino Uno  Arduino Uno
2. Arduino Leonardo
3. Arduino Nano
4. Arduino/Genuino Micro  Arduino Micro
2 Choose the COM number ::
Tools  Port  “ Select your Port “
Ready cods to use in your projects
It is used widely to know how the devices work.
likes : Servo motor , Stepper motor , LCD crystal
Serial communication , SD cards , wifi ……. etc
For Statement if Statement Switch Case Statement
for (initialization; condition; increment)
{ //statement(s); }
3
3
Parts :
1. Led ( Digital Out device )
2. Push Bottom (Digital in device )
3. Wires
4. Arduino
5. Bread Board
6. Carbon Resistance
3
3
Task :
Make a Traffic light with three led (Yellow , Green , Red )
Green HIGH  delay 1000 ms  Green LOW
delay 200 ms
Yellow HIGH  delay 1000ms Yellow LOW
delay 200 ms
Red HIGH  delay 1000ms  Red LOW
delay 200 ms
3
Parts :
1. Arduino
2. Wires
3. Push Bottom
4. Carbon Resistance
3
3 4
Parts :
1. Arduino
2. Wires
3. Variable resistance
4. Colored Led
5. Sensors.
Task is : to control the led light density by variable Resistance.
3 4
While the code is running , try to open :
Tools  Serial Plotter
3
Map  is a function defined in Arduino C language .
we use it to Re-maps a number from one range to another .
General form:
New_range = map (val , from min , from max , to min , to max);
In pervious example:
New_val = map(val, 0 , 1023 , 0 , 255) ;
// its convert val from (0-1023) range to (0-512)
3
Tow Thing you have start with:
1. Get the data sheet
2. find the range of measuring.
3. Use the map() function.
Example:
I have to measure the temperature in my room.
The sensor needed is TMP36 sensor. How can I start with ?!
1. Search in google for [TMP36 sensor].
2. Find the voltage range.
3. Find the measuring range.
4. Try to know how dose the sensor work.
3
In the pervious (ATMP36 )sensor .
if I need to eliminate the measured temperature values.
Measure from (0C to 100C for example )
Google it and teach yourself ☺
3
Parts : 3-Colored Led
Potentiometer
Bread Board
Jumper Wires
Task : Read analog Signal from Potentiometer,
and Light on Led as Indicator
0
100
200
300
4
4
Stepper
Dc
Servo
4
DC Motors
* Arduino Run Dc motors and controlling its speed by PWM , By code
analogWrite(pin,255);
* Arduino can Supply 5volt up to 400mA ,
to run 12volt Dc motors we need H-bridge
Dc Motor for Arduino Car Kite
“ 5 volt “
General Purpose Motor
“ 5 volt ”
High Power Dc motor
“ 12 volt ”
Servo Motors
* Motor rotates with certain angles in [Degrees], i.e: 60 , 90 , 180 …
* <Servo.h> Library used to drive the Servo Motor
Micro ServoBig Black Servo
4
#include <Servo.h>
Servo myservo; // create myservo
object to control a servo
myservo.attach(9); // attaches
the servo on pin 9 to the servo
object
myservo.write(pos); // tell servo to go
to position in variable 'pos'
4.2
The data Transmitted and Reserved Serially
Serial Data Flow
Baud Rate : how fast data Transmitted
Expressed in [Bit Per Second]
Serial Communication Between Arduino
and Serial-Monitor
Serial Communication Between two Arduinos
Bluetooth HC-06
Serial Communication Between two Arduino
And Smart-phone via Bluetooth
Example: Messenger Between Tow Arduinos
First Method Using Default Serial Communication Pins (0 & 1 )
What To Do in points !!
Read what The Other
Send to me !
This Happen by reading From
Serial Monitor
Replay To massages
By Writing on The
Serial Monitor
Example: Messenger Between Tow Arduinos
Messenger Between
Tow Arduinos
Arduino Code
4.3
There are many types of LCD screen the most common is :
16x2 LCD Crystal Screen
Consist from 2 lines and 16 column
20x4 LCD Crystal Screen
Consist from 4 lines and 20 column
Nokia 5110 LCD
Consist from 84x48 pixel
4 3
4.3
#include <LiquidCrystal.h>
lcd.begin() // to initiate the LCD
setCursor() //to set the pose of
printing on LCD
lcd.print() // to print on LCD
lcd.clear() // to clear LCD from Texts

Starting with Arduino

  • 1.
    ‫إعداد‬:‫شماسنة‬ ‫مجدي‬‫لعام‬ ‫والبرمجة‬‫األردوينو‬ ‫لدورة‬ ‫خصيصا‬ ‫األوراق‬ ‫هذه‬ ‫عدت‬ُ‫أ‬2017‫لنادي‬Imech E‫بيرزيت‬ ‫جامعة‬ ‫فرع‬
  • 2.
    The contents ofthis Course : This course is a workshop ( no much of Theories ) , so will involve in : 1. Identify the ARDUINO board parts and their works / power suppling methods / output and input pins . 2. Identify the Basic programming functions ( reading inputs and returning Outputs ) 3. Identify the signals types that the ARDUINO treat with 4. Using sensors : a. measuring the room temp b. measuring the light intensity c. detection the movement . d. Making a distance measuring tool ( using ultrasonic sensor ) e . --- working on a new sensor individuality ---
  • 3.
    6. Using motors: a . DC motor b. servo motor c. stepper motor 5. Identify the H-BRIDGE and its usage 7. Using the KeyPad 8. Identify Serial interface 9. Using LCD display. 10 . -- Task : making a personal messenger -- 11. Using a inferred IR sensor with remote Control 12 . use a seven segment screen *** if there enough time , we will Do a PID Control by ARDUINO ☺
  • 4.
    Arduino : isa MICROCONTROLLER , able to be programmed by the users via ( Arduino c programming) . ( in fact , it is a Tiny computer ) MICROCONTROLLER : integrated circuit (fig 1.1) , contain CPU , memory ( RAM, ROM, Flash) , inputs & outputs ports Fig 1.1 : Integrated circuits
  • 5.
    Arduino Uno Arduino Leonardo ArduinoMega Arduino LilyPad Arduino Nano Arduino mini Cortino (ARM) LeafLabs Maple
  • 6.
    3 1 1. USB cable 2.External power supply 3. ATMEGA328 microcontroller 4. USB to Serial controller 5. 5V regulator 6. 16 MHz crystal 7. Rest push Potton 8. Ground (GND) 9. ( 5 ) volt output power 10. ( 3.3 ) output power 11. Input power pin 12. Analog input pins 13. Analog output pins ( ~3,~5,~6,~9,~10,~11) 14. Digital output / input pins ( All pins) 15. TX,RX led 16. Led connected with pin 13 17. Power indicator 2 3 4 5 6 7 8910 11 12 131415 16 17
  • 7.
    Rated Power (7-12 ) volt This done By : 1. Power Jet ( Battery ) 1. Another circuit 1. USB cable 1 2 3 1 2 3 Vin
  • 8.
    Digital Signal :Is a signal consists from tow values ( 0 or 1 ) To read a digital signal use the function : digitalRead(); To write a digital signal use the function : digitalWrite (); In Arduino : (logic 0) = ( volts 0) = LOW = OFF ( logic 1) = (volts 5) = HIGH = ON Digital signals received and send by using the 14 pins
  • 9.
    1 give aname for the pin “Optional” 1 2 Open the pin mode as ( INPUT / OUTPUT) 2 3 The pin is ready to Use by its name or By its number
  • 10.
    Analog Signal :Is a sinusoidal signal To read an Analog signal use the function : analoglRead(); To write a digital signal use the function : analogWrite (); Analog signals received by using the (A0 …. A5) pins Analog signals sent by using the (~3 , ~5, ~6, ~9 ,~10, ~11) pins Arduino treat with this type of signals as a ( 8 bit digital data ) (0 – 5 volt)  (0 – 255)
  • 11.
    1 give aname for the pin “Optional” 2 Open the pin mode as ( INPUT / OUTPUT) 3 The pin is ready to Use by its name or By its number 1 2 3
  • 12.
    1 Lab ViewInterfacing 2 Mathlab Interfacing
  • 13.
    3 Arduino IDE IDE: Integrated Development Environment Free program , you can get it from : https://www.arduino.cc/download_handler.php
  • 14.
    1 Verify :to check the code and catch the syntax Errors 5 Upload : to Save your Work on Your Computer 3 New : to Open New Sketch 4 Upload : to Open a Existence Sketch (Saved on Computer Before ) 2 Upload : to upload the code on the Arduino chip 6 Serial Monitor : to Open The Serial Monitor ( an Interfacing Monitor ) 7 Sketch Name : Shows the Name of Current Sketch 8 Coad Area : Coding Area 9 Massage Area : Show the Errors after Compile 10 Text Console : Show a full Error Massage 11 Board and Serial Port : Arduino COM number
  • 15.
    1 Choose YourArduino Type :: Tools  Board  “ Select yours Board “ Most common boards : 1. Arduino /Genuino Uno  Arduino Uno 2. Arduino Leonardo 3. Arduino Nano 4. Arduino/Genuino Micro  Arduino Micro
  • 16.
    2 Choose theCOM number :: Tools  Port  “ Select your Port “
  • 17.
    Ready cods touse in your projects It is used widely to know how the devices work. likes : Servo motor , Stepper motor , LCD crystal Serial communication , SD cards , wifi ……. etc
  • 18.
    For Statement ifStatement Switch Case Statement
  • 20.
    for (initialization; condition;increment) { //statement(s); }
  • 22.
  • 23.
    3 Parts : 1. Led( Digital Out device ) 2. Push Bottom (Digital in device ) 3. Wires 4. Arduino 5. Bread Board 6. Carbon Resistance
  • 24.
  • 25.
    3 Task : Make aTraffic light with three led (Yellow , Green , Red ) Green HIGH  delay 1000 ms  Green LOW delay 200 ms Yellow HIGH  delay 1000ms Yellow LOW delay 200 ms Red HIGH  delay 1000ms  Red LOW delay 200 ms
  • 26.
    3 Parts : 1. Arduino 2.Wires 3. Push Bottom 4. Carbon Resistance
  • 28.
  • 29.
    3 4 Parts : 1.Arduino 2. Wires 3. Variable resistance 4. Colored Led 5. Sensors. Task is : to control the led light density by variable Resistance.
  • 30.
    3 4 While thecode is running , try to open : Tools  Serial Plotter
  • 31.
    3 Map  isa function defined in Arduino C language . we use it to Re-maps a number from one range to another . General form: New_range = map (val , from min , from max , to min , to max); In pervious example: New_val = map(val, 0 , 1023 , 0 , 255) ; // its convert val from (0-1023) range to (0-512)
  • 32.
    3 Tow Thing youhave start with: 1. Get the data sheet 2. find the range of measuring. 3. Use the map() function. Example: I have to measure the temperature in my room. The sensor needed is TMP36 sensor. How can I start with ?! 1. Search in google for [TMP36 sensor]. 2. Find the voltage range. 3. Find the measuring range. 4. Try to know how dose the sensor work.
  • 33.
    3 In the pervious(ATMP36 )sensor . if I need to eliminate the measured temperature values. Measure from (0C to 100C for example ) Google it and teach yourself ☺
  • 34.
    3 Parts : 3-ColoredLed Potentiometer Bread Board Jumper Wires Task : Read analog Signal from Potentiometer, and Light on Led as Indicator 0 100 200 300
  • 36.
  • 37.
  • 38.
    4 DC Motors * ArduinoRun Dc motors and controlling its speed by PWM , By code analogWrite(pin,255); * Arduino can Supply 5volt up to 400mA , to run 12volt Dc motors we need H-bridge Dc Motor for Arduino Car Kite “ 5 volt “ General Purpose Motor “ 5 volt ” High Power Dc motor “ 12 volt ”
  • 41.
    Servo Motors * Motorrotates with certain angles in [Degrees], i.e: 60 , 90 , 180 … * <Servo.h> Library used to drive the Servo Motor Micro ServoBig Black Servo 4
  • 42.
    #include <Servo.h> Servo myservo;// create myservo object to control a servo myservo.attach(9); // attaches the servo on pin 9 to the servo object myservo.write(pos); // tell servo to go to position in variable 'pos'
  • 43.
    4.2 The data Transmittedand Reserved Serially Serial Data Flow Baud Rate : how fast data Transmitted Expressed in [Bit Per Second]
  • 44.
    Serial Communication BetweenArduino and Serial-Monitor
  • 45.
  • 46.
    Bluetooth HC-06 Serial CommunicationBetween two Arduino And Smart-phone via Bluetooth
  • 47.
    Example: Messenger BetweenTow Arduinos First Method Using Default Serial Communication Pins (0 & 1 )
  • 48.
    What To Doin points !! Read what The Other Send to me ! This Happen by reading From Serial Monitor Replay To massages By Writing on The Serial Monitor Example: Messenger Between Tow Arduinos
  • 49.
  • 50.
    4.3 There are manytypes of LCD screen the most common is : 16x2 LCD Crystal Screen Consist from 2 lines and 16 column 20x4 LCD Crystal Screen Consist from 4 lines and 20 column Nokia 5110 LCD Consist from 84x48 pixel
  • 51.
  • 52.
    4.3 #include <LiquidCrystal.h> lcd.begin() //to initiate the LCD setCursor() //to set the pose of printing on LCD lcd.print() // to print on LCD lcd.clear() // to clear LCD from Texts