Arduino Eng: Ali M. Lakkis
Outline I. What is a Microcontroller II. What is a Development Board III. Arduino / Breadboard Pin-out IV. Basic Electric Components 2
What is a microcontroller? A small computer on a single chip:  containing a processor, memory, and input/output. Typically "embedded" inside some devices that they control. A microcontroller is often small and low cost. 3
What is a Development Board? A printed circuit board designed to facilitate work with a particular microcontroller. Typical components include:  power circuit  programming interface  Basic input; usually buttons and LEDs  I/O pins 4
Arduino pins out (1/3) 5
Arduino pins out (2/3) 6
Arduino pins out (3/3) 7
Basic electronic components (1/6) • LED stands for Light Emitting Diode. The diode is a critical element in this lamp where the it doesn’t allow the circulation of the current except of a 1 way, and hence the triangular shape in along with the bounding line. • The lamp has 2 legs, the long one should always be connected to the positive side of the circuit, the short one that has to be connected to the negative side of the circuit. 8
Basic electronic components (2/6) • DC motor will be the main element that will allow your robots to move. These motors are connect to the electric source through the wires, increasing the current in the wires, increases the speed of the motors, reversing the direction of the current reverses the rotational direction of the motor. 9
Basic electronic components (3/6) • Servo Motors are accurate motors that can be controlled by the degree. These motors will be very helpful in executing accurate actions. 10
Basic electronic components (4/6) • Motor Driver or usually known as H- Bridge is a control unit that is used to control the rotational direction of DC motors. • This unit allow the robots to maneuver around any task. 11 • When 2 motors spin forward the whole robot moves forward. • When the motors spin backward, the whole robot goes backwards. • When the motors spin against each other the robot would be turning around itself.
12
Basic electronic components (5/6) • Ultrasound sensor uses radio waves in order to detect distances, it allows the robot to literally identify how far are the objects from the robot. You will use this sensor in the competition in order to solve a maze. 13
Basic electronic components (5/6) • Color sensor detects the color of the surface, usually in the RGB scale. Color is the result of interaction between a light source, an object and an observer. • It calculate the chromaticity coordinates from the reflected radiation and compare them with previously stored reference colors. 14
Outline V. Getting Started VI. Intro to Programming Arduino VII. Sensors and motors with Arduino VIII.Motor control IX. Control servo motors I. Obstacle Avoider 15
Getting started (1/7) 16 Download & install the Arduino environment (IDE): is used to write, compile, and upload programs to Arduino. (https://www.arduino.cc)
Getting started (2/7) Connect the board to your computer via the UBS cable: 17
Getting started (3/7) 18
Getting started (4/7) 19
Getting started (5/7) • Using Arduino: Write your sketch. Press Compile button or Ctrl+R ( to check for errors). Press Upload button or Ctrl+U to program Arduino board with you sketch. • Try it out with the “Blink” sketch. 20 Compile Upload
Getting started (6/7) 21
Getting started (7/7) 22 Status Messages: Uploading worked Wrong Serial Port Wrong Board
Intro to Programming Arduino (1/34) • Basic Syntaxes 23 ; Semicolon Semicolons must always be used at end of each statement in your code. // Line Comments comments are used on order to clarify the written statements Variables Variables describe the type of the data you are using, which might be: Integer (Int) : any negative or Positive number excluding decimals Boolean (Bool) : only 0 or 1 Character : char used for characters such as letters
Intro to Programming Arduino (2/34) 24 • Basic Syntaxes INPUT/OUTPUT These variables set pins for being inputs or outputs. HIGH/LOW These variables set the pins to high as ON or low as OFF. PINMODE pinMode is used in the setup part where you can use it to set up the Arduino Pins General statement : pinMode(pin#,OUTPUT or INPUT) Example : pinMode (13,INPUT) Here we have set Pint # 13 to act as an input
Intro to Programming Arduino (3/34) 25 • Basic Syntaxes digitalWrite digitalWrite is used to write or post on a pin the requested value usually it is either HIGH or LOW general statement : digitalWrite (pin, value) Example : digitalWrite (13, HIGH) here we have set pin #13 to be high, hence it will be giving current or ON digitalRead digitalRead is used to read in the data from a specific Pin general Statement: digitalRead(pin) Example: digitalRead(13) Here we have set the Arduino to read from pin 13.
Intro to Programming Arduino (4/34) 26 analogWrite analogWrite is used to write or post on a pin the requested value from 0 to 255 usually general statement :analogWrite (pin, value) Example : analogWrite (13, 128) here we have set pin #13 to be high, hence it will be giving a current relative to value of 128 analogRead analogRead is used to read in the data from a specific Pin general Statement: analogRead(pin) Example: analogRead( 13) Here we have set the Arduino to read from pin 13 the analog input • Basic Syntaxes
Intro to Programming Arduino (5/34) 27 • Basic Syntaxes Pulse Width Modulation, or PWM It is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off.
Intro to Programming Arduino (6/34) 28 • Example 1: Fading LEDs with Arduino
Intro to Programming Arduino (26/34) 29 • Example 9: Line follower
Intro to Programming Arduino (27/34) 30
Intro to Programming Arduino (28/34) 31
Intro to Programming Arduino (9/34) 32 • Example 3: Distance Measuring Using Ultrasound Sensor
Intro to Programming Arduino (10/34) 33
Intro to Programming Arduino (11/34) 34 • Example 4: Ultrasound Sensor with LED
Intro to Programming Arduino (12/34) 35
Intro to Programming Arduino (13/34) 36 • Example 5: Servo motors
37  Tell the Arduino what pin your servo is attached to.  Include a serial connection to check the values.  Set up constant for the pin the potentiometer is attached to.  Variables to hold the analog input value and angle to move the servo to.  Import servo library.  Create object refer to the servo.  Read the analog input and print out the value to the serial monitor. Intro to Programming Arduino (14/34)
Intro to Programming Arduino (15/34) 38  Use map() function to map the analog value into degrees.  Print out the angle into the serial monitor.  Send the value to the servo and give it some time to move to the target angle.
39 Intro to Programming Arduino (16/34) Example 6: Ultrasound Radar
40 Intro to Programming Arduino (17/34)
41  This Part is an independent function -must be written outside the void loop()- for calculating the distance and limit it to 20 cm for every object far more than 20cm. Intro to Programming Arduino (18/34)
42 Intro to Programming Arduino (19/34)
43 Intro to Programming Arduino (20/34)
Intro to Programming Arduino (21/34) 44 • Example 7: DC Motor speed control
Intro to Programming Arduino (22/34) 45
Intro to Programming Arduino (23/34) 46 • Example 8: DC Motor speed and rotation
Intro to Programming Arduino (24/34) 47 Continue next slide
Intro to Programming Arduino (25/34) 48
Intro to Programming Arduino (29/34) 49 • Example 10: Bluetooth module with Arduino Bluetooth Controller App
Intro to Programming Arduino (30/34) 50
First experience with robots (31/34) 51 AND NOW… It is time to test the ROBOT!!! 1. First we must define the pins on which we are connecting the sensors, motors,… as shown .
First experience with robots (32/34) 52 2. Then, include the corresponding libraries if available to be used in the code . 3. Setup your code.
First experience with robots (33/34) 53 4. In the void loop, put your algorithm code which controls the robot
First experience with robots (34/34) 54

Arduino presentation that talks about basics of arduino.pptx

  • 1.
  • 2.
    Outline I. What isa Microcontroller II. What is a Development Board III. Arduino / Breadboard Pin-out IV. Basic Electric Components 2
  • 3.
    What is amicrocontroller? A small computer on a single chip:  containing a processor, memory, and input/output. Typically "embedded" inside some devices that they control. A microcontroller is often small and low cost. 3
  • 4.
    What is aDevelopment Board? A printed circuit board designed to facilitate work with a particular microcontroller. Typical components include:  power circuit  programming interface  Basic input; usually buttons and LEDs  I/O pins 4
  • 5.
  • 6.
  • 7.
  • 8.
    Basic electronic components (1/6) •LED stands for Light Emitting Diode. The diode is a critical element in this lamp where the it doesn’t allow the circulation of the current except of a 1 way, and hence the triangular shape in along with the bounding line. • The lamp has 2 legs, the long one should always be connected to the positive side of the circuit, the short one that has to be connected to the negative side of the circuit. 8
  • 9.
    Basic electronic components(2/6) • DC motor will be the main element that will allow your robots to move. These motors are connect to the electric source through the wires, increasing the current in the wires, increases the speed of the motors, reversing the direction of the current reverses the rotational direction of the motor. 9
  • 10.
    Basic electronic components(3/6) • Servo Motors are accurate motors that can be controlled by the degree. These motors will be very helpful in executing accurate actions. 10
  • 11.
    Basic electronic components (4/6) •Motor Driver or usually known as H- Bridge is a control unit that is used to control the rotational direction of DC motors. • This unit allow the robots to maneuver around any task. 11 • When 2 motors spin forward the whole robot moves forward. • When the motors spin backward, the whole robot goes backwards. • When the motors spin against each other the robot would be turning around itself.
  • 12.
  • 13.
    Basic electronic components (5/6) •Ultrasound sensor uses radio waves in order to detect distances, it allows the robot to literally identify how far are the objects from the robot. You will use this sensor in the competition in order to solve a maze. 13
  • 14.
    Basic electronic components (5/6) •Color sensor detects the color of the surface, usually in the RGB scale. Color is the result of interaction between a light source, an object and an observer. • It calculate the chromaticity coordinates from the reflected radiation and compare them with previously stored reference colors. 14
  • 15.
    Outline V. Getting Started VI.Intro to Programming Arduino VII. Sensors and motors with Arduino VIII.Motor control IX. Control servo motors I. Obstacle Avoider 15
  • 16.
    Getting started (1/7) 16 Download& install the Arduino environment (IDE): is used to write, compile, and upload programs to Arduino. (https://www.arduino.cc)
  • 17.
    Getting started (2/7) Connectthe board to your computer via the UBS cable: 17
  • 18.
  • 19.
  • 20.
    Getting started (5/7) •Using Arduino: Write your sketch. Press Compile button or Ctrl+R ( to check for errors). Press Upload button or Ctrl+U to program Arduino board with you sketch. • Try it out with the “Blink” sketch. 20 Compile Upload
  • 21.
  • 22.
    Getting started (7/7) 22 StatusMessages: Uploading worked Wrong Serial Port Wrong Board
  • 23.
    Intro to ProgrammingArduino (1/34) • Basic Syntaxes 23 ; Semicolon Semicolons must always be used at end of each statement in your code. // Line Comments comments are used on order to clarify the written statements Variables Variables describe the type of the data you are using, which might be: Integer (Int) : any negative or Positive number excluding decimals Boolean (Bool) : only 0 or 1 Character : char used for characters such as letters
  • 24.
    Intro to ProgrammingArduino (2/34) 24 • Basic Syntaxes INPUT/OUTPUT These variables set pins for being inputs or outputs. HIGH/LOW These variables set the pins to high as ON or low as OFF. PINMODE pinMode is used in the setup part where you can use it to set up the Arduino Pins General statement : pinMode(pin#,OUTPUT or INPUT) Example : pinMode (13,INPUT) Here we have set Pint # 13 to act as an input
  • 25.
    Intro to ProgrammingArduino (3/34) 25 • Basic Syntaxes digitalWrite digitalWrite is used to write or post on a pin the requested value usually it is either HIGH or LOW general statement : digitalWrite (pin, value) Example : digitalWrite (13, HIGH) here we have set pin #13 to be high, hence it will be giving current or ON digitalRead digitalRead is used to read in the data from a specific Pin general Statement: digitalRead(pin) Example: digitalRead(13) Here we have set the Arduino to read from pin 13.
  • 26.
    Intro to ProgrammingArduino (4/34) 26 analogWrite analogWrite is used to write or post on a pin the requested value from 0 to 255 usually general statement :analogWrite (pin, value) Example : analogWrite (13, 128) here we have set pin #13 to be high, hence it will be giving a current relative to value of 128 analogRead analogRead is used to read in the data from a specific Pin general Statement: analogRead(pin) Example: analogRead( 13) Here we have set the Arduino to read from pin 13 the analog input • Basic Syntaxes
  • 27.
    Intro to ProgrammingArduino (5/34) 27 • Basic Syntaxes Pulse Width Modulation, or PWM It is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off.
  • 28.
    Intro to ProgrammingArduino (6/34) 28 • Example 1: Fading LEDs with Arduino
  • 29.
    Intro to ProgrammingArduino (26/34) 29 • Example 9: Line follower
  • 30.
    Intro to ProgrammingArduino (27/34) 30
  • 31.
    Intro to ProgrammingArduino (28/34) 31
  • 32.
    Intro to ProgrammingArduino (9/34) 32 • Example 3: Distance Measuring Using Ultrasound Sensor
  • 33.
    Intro to ProgrammingArduino (10/34) 33
  • 34.
    Intro to ProgrammingArduino (11/34) 34 • Example 4: Ultrasound Sensor with LED
  • 35.
    Intro to ProgrammingArduino (12/34) 35
  • 36.
    Intro to ProgrammingArduino (13/34) 36 • Example 5: Servo motors
  • 37.
    37  Tell theArduino what pin your servo is attached to.  Include a serial connection to check the values.  Set up constant for the pin the potentiometer is attached to.  Variables to hold the analog input value and angle to move the servo to.  Import servo library.  Create object refer to the servo.  Read the analog input and print out the value to the serial monitor. Intro to Programming Arduino (14/34)
  • 38.
    Intro to Programming Arduino(15/34) 38  Use map() function to map the analog value into degrees.  Print out the angle into the serial monitor.  Send the value to the servo and give it some time to move to the target angle.
  • 39.
    39 Intro to Programming Arduino(16/34) Example 6: Ultrasound Radar
  • 40.
  • 41.
    41  This Partis an independent function -must be written outside the void loop()- for calculating the distance and limit it to 20 cm for every object far more than 20cm. Intro to Programming Arduino (18/34)
  • 42.
  • 43.
  • 44.
    Intro to ProgrammingArduino (21/34) 44 • Example 7: DC Motor speed control
  • 45.
    Intro to ProgrammingArduino (22/34) 45
  • 46.
    Intro to ProgrammingArduino (23/34) 46 • Example 8: DC Motor speed and rotation
  • 47.
    Intro to ProgrammingArduino (24/34) 47 Continue next slide
  • 48.
    Intro to ProgrammingArduino (25/34) 48
  • 49.
    Intro to Programming Arduino(29/34) 49 • Example 10: Bluetooth module with Arduino Bluetooth Controller App
  • 50.
    Intro to ProgrammingArduino (30/34) 50
  • 51.
    First experience withrobots (31/34) 51 AND NOW… It is time to test the ROBOT!!! 1. First we must define the pins on which we are connecting the sensors, motors,… as shown .
  • 52.
    First experience withrobots (32/34) 52 2. Then, include the corresponding libraries if available to be used in the code . 3. Setup your code.
  • 53.
    First experience withrobots (33/34) 53 4. In the void loop, put your algorithm code which controls the robot
  • 54.
    First experience withrobots (34/34) 54