Arduino Class DOC - 20230430 - WA0001
Arduino Class DOC - 20230430 - WA0001
Arduino Class DOC - 20230430 - WA0001
Lesson 5:
Introduction to Arduino
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, July 2017 - 19
Mechatronics, Controls, and Robotics Laboratory, Department of Mechanical and Aerospace Engineering, NYU Tandon School of Engineering
CONTENTS
• Microcontrollers and microprocessors
• Introduction to Arduino
• Types of Arduino boards
• Programming basics: Structure of a code
• TASK/ACTIVITY:
➢ Blink on-board LED
➢ Blink LED(s)
➢ Change brightness of LEDs
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 2
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
WHAT IS A MICROCONTROLLER?
New Lesson
• A compact - Photos
integrated circuit on a
single chip containing a processor,
memory, and input/output as its main
components
• Typically, it is "embedded" inside a
device that is controlL E DS
• A microcontroller is often small and of
low cost
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 3
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
MICROPROCESSOR VS MICROCONTROLLER
Source
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 4
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
MORE ABOUT THE DEVICES
What is the difference between a computer, a microprocessor and a
New Lesson - Photos
microcontroller?
• Microprocessor is a full computation engine fabricated on a single chip; It acts
as the central processing unit (CPU) of a microcomputer
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 5
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
COMPONENTS OF A ROBOT
• As discussed earlier:
Source
Source
Source
Source
Source
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
6
WHAT IS ARDUINO???
• ArduinoNew
is an open-source
Lesson electronic
- Photos
platform for easy use of hardware and
software
Arduino
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 7
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
WHAT DOES IT DO???
• Working: The microcontroller (computer) is programmed (code) to receive
information (input) from the sensors and the output is given through
computer (IDE) or other peripherals
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 8
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
ACTIVITY 1
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 9
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
ACTIVITY 1 - SOLUTION
• What is the circuit doing?
Light up the on-board LED
on button press
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 11
DIFFERENT TYPES OF ARDUINO
Arduino LilyPad
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 12
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
DIFFERENT TYPES OF ARDUINO
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 13
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
DIFFERENT TYPES OF ARDUINO
LED cube powered by Arduino App controlled trainable arm with Arduino
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 15
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
PROJECTS BASED ON ARDUINO
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 16
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
PROJECTS BASED ON ARDUINO - NYU
• Human-following luggage with Arduino:
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 17
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
PROJECTS BASED ON ARDUINO - NYU
• Jarvis – Voice assistant with Arduino:
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 18
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
ARDUINO UNO DEVELOPMENT BOARD
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 19
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
ARDUINO HARDWARE SUMMARY
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 20
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
. ACTIVITY 2
Check out: http://arduino.cc/en/Guide/HomePage
cable
3. If needed, install the drivers
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers 21
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19
. POWERING UP THE ARDUINO WITH USB
• Connecting via USB cable to load the code and provide power at the same time
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 23
. ACTIVITY 3
Source
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 25
A LITTLE BIT ABOUT THE CODE
Sketch: Arduino code is referred to as sketch and consists of: Sketch
void setup() {
• Instructions between the two curly brackets will be run
only once when the Arduino program first runs and used
for the purpose of setup
• Initialize I/O pins (directions), initialize serial
communication, etc.
}
• /*
Multi line comment, or block‐comment
• */
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 28
UPLOADING YOUR CODE
• Select your board Arduino
UNO
• Select your port from tools
• Upload the code to the
Arduino as shown
• Check for errors
• Check if the code is
compiled successfully
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 29
BLINK AN EXTERNAL LED
Things to remember:
1. Longer leg (Anode) of the LED goes to one end of the resistor in series and the
other end of resistor goes to pin (3) here
2. Shorter leg (Cathode) goes to ground (GND)
Cathode Anode
Source
Blink LED
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 30
ACTIVITY 4
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 31
ACTIVITY 4 - SOLUTION
➢ Connections:
Pins: 6, GND
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 32
ACTIVITY 4 - SOLUTION
➢ Code:
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 33
PROGRAMMING ESSENTIALS: I/O
• Digital I/O pins:
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 34
PROGRAMMING ESSENTIALS: I/O
digitalRead(pin)
• Reads the value from a specified digital pin with the result being 1 (HIGH) or 0
(LOW)
• Pin can be specified as a variable or constant (0-13)
➢ Syntax: value = digitalRead(pin); //sets 'value' equal to the state of the input pin
digitalWrite(pin, value)
• Pin refers to a digital pin, can be a variable or a constant (0-13)
• Value is either logic level HIGH/LOW, TRUE/FALSE, 1/0
• Outputs either logic level HIGH or LOW at a specified digital pin
➢ Syntax: digitalWrite(pin, value); //sets 'value’ as the state of the input pin
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 35
PROGRAMMING ESSENTIALS: I/O
analogRead(pin)
• Reads the value from a specified analog pin with a 10-bit resolution
• Pin argument can be specified as a variable or constant (0-5)
• Resulting integer values range from 0 to 1023 and must be scaled to
appropriate units
analogWrite(pin, value)
• Outputs a PWM signal to the specified output pin
• This function works on pins 3, 5, 6, 9, 10, and 11
• Value can be specified as a variable or constant with range 0-255
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 37
ACTIVITY 5 - SOLUTION
➢ Connections:
Pins: 10, 11, GND
Source Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 38
ACTIVITY 5 - SOLUTION
➢ Code:
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 39
PROGRAMMING ESSENTIALS
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 40
PWM BASIC CONCEPTS
• Pulse width modulation (PWM): Converts a digital
value to analog output
• Pulse width modulation (PWM) allows Arduino to
generate a series of pulses
• When a pin is output high, the apparent voltage at that
pin will be close to 5 V
• When the pin is made output low it is close to 0 V
Source
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 41
PWM BASIC CONCEPTS
Source
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 42
ACTIVITY 6
• Attach one LED to your Arduino and write a program to change its
brightness
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 43
ACTIVITY 6 - SOLUTION
New Lesson - Photos
➢ Connections:
Pins: 6, GND
Source
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 44
ACTIVITY 6 - SOLUTION
➢ Code:
New Lesson - Photos
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 45
STATUS MESSAGES
Successful upload: Wrong port selected:
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 46
ACTIVITY 7
New Lesson - Photos
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 47
ACTIVITY 7 - SOLUTION
Cathode
New Lesson - Photos Anode
➢ Connections:
Pins: 3, 6, 9, 10, 11, GND
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 48
ACTIVITY 7 - SOLUTION
➢ Code:
New Lesson - Photos
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 49
ACTIVITY 7 - SOLUTION
New Lesson - Photos
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 50
VARIABLES
• A variable is a place to store a piece of data
• It has a name, a value, a type and size accordingly
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 51
VARIABLES
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 52
ACTIVITY 8
New Lesson - Photos
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 53
ACTIVITY 8 - SOLUTION
New Lesson - Photos
int a = 5; int a = 5;
int b = 2; int b = 2;
int c = 0; float c = 0;
c = a / b; c = a / b;
Promoting Robotic Design and Entrepreneurship Experiences Among Students and Teachers
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, NYU Tandon School of Engineering, July 2017-19 54
Thank You!
Questions and Feedback?
Innovative Technology Experiences for Students and Teachers (ITEST), Professional Development Program, July 2017 - 19
Mechatronics, Controls, and Robotics Laboratory, Department of Mechanical and Aerospace Engineering, NYU Tandon School of Engineering