EMBEDDED SYSTEMS AND IoT UNIT 3
Embedded Systems and Internet of Things
Arduino IDE Programming 1
EMBEDDED SYSTEMS AND IoT UNIT 3
UNIT 3
3.1 Introduction to the Concept of IoT Devices
3.2 IoT Devices Versus Computers
3.3 IoT Configurations - Basic Components
3.4 Introduction to Arduino – Types of Arduino
3.5 Arduino Toolchain
3.6 Arduino Programming Structure – Sketches – Pins –
Input/Output From Pins Using Sketches
3.7 Introduction to Arduino Shields
3.8 Integration of Sensors and Actuators with Arduino.
Arduino IDE Programming 2
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Topics to be Covered
• Arduino Integrated Development Environment (IDE)
• Steps in Arduino Programming
• Using Arduino
• Adding an External LED to pin 13
• Toolbar
• Arduino Code
• Terminology
• Basic Hardware Functions
• Basic Software Functions
• Some Other Basic Functions
Module 4 – Building IoT with Galileo/Arduino 3
Arduino IDE
Arduino Integrated Development Environment (IDE)
• The Arduino IDE is a cross-platform application
• For the Windows, macOS, Linux
• The Arduino IDE supports the languages C and C++ using special rules of
code structuring
• The Arduino IDE can be downloaded for the OS
from https://www.arduino.cc/en/Main/Software
Module 4 – Building IoT with Galileo/Arduino 4
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Steps in Arduino Programming
1. Download & install the Arduino environment (IDE)
Module 4 – Building IoT with Galileo/Arduino 5
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Steps in Arduino Programming
2. Connect the board to your computer via the UBS cable
3. If needed, install the drivers (not needed in lab)
Module 4 – Building IoT with Galileo/Arduino 6
Arduino IDE
Steps in Arduino Programming
4. Launch the Arduino IDE
Module 4 – Building IoT with Galileo/Arduino 7
Arduino IDE
Steps in Arduino Programming
5. Select Serial Port and Board
Module 4 – Building IoT with Galileo/Arduino 8
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Toolbar
• Verify
✔ Checks code for errors compiling it
• Upload
✔ Compiles and uploads code to the Arduino I/O board
• New
✔ Creates a new sketch
• Open
✔ Open sketch
• Save
✔ Save sketch
• Serial Monitor
✔ Display serial data being sent from the Arduino board
Module 4 – Building IoT with Galileo/Arduino 9
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Using Arduino
• Write the sketch
• Press Compile button (to check for errors)
• Press Upload button to program Arduino
board with your sketch
Example with the “Blink” sketch
Load “File/Sketchbook/Examples/Digital/Blink”
Module 4 – Building IoT with Galileo/Arduino 10
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Steps in Arduino Programming
7. Upload the program
Module 4 – Building IoT with Galileo/Arduino 11
Arduino IDE
Steps in Arduino
Programming
6. Open the blink example program or type the program
12
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Steps in Arduino Programming
8. After Uploading
Module 4 – Building IoT with Galileo/Arduino 13
Arduino IDE
Adding an External LED to pin 13
• File → Examples → Digital → Blink
• LED’s have polarity
✔ Negative indicated by flat side of the housing and a short leg
Module 4 – Building IoT with Galileo/Arduino 14
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Arduino Code
• Code is case sensitive
• Statements are commands and must end with a semi-colon
• To run a program in Arduino, the sketch should contain two
methods
Module 4 – Building IoT with Galileo/Arduino 15
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Terminology
• Sketch
✔ A program written to run on an Arduino board
• Pin
✔ An input or output connected to something. E.g., output to an LED, input
from a knob
• Digital
✔ Value is either HIGH or LOW. (aka on/off, one/zero) E.g., switch state
• Analog
✔ Value ranges, usually from 0 – 255. E.g., LED brightness, motor speed, etc.
Module 4 – Building IoT with Galileo/Arduino 16
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Basic Hardware Functions
pinMode(pin, mode)
✔ Sets pin to either INPUT or OUTPUT
digitalRead(pin)
✔ Reads HIGH or LOW from a pin
digitalWrite(pin, value)
✔ Writes HIGH or LOW to a pin
Module 4 – Building IoT with Galileo/Arduino 17
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Basic Software Functions
If-then-else
For Lop
Module 4 – Building IoT with Galileo/Arduino 18
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Basic Software Functions
Switch
Module 4 – Building IoT with Galileo/Arduino 19
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Some Other Basic Functions
• delay(ms)
✔ Pauses for a few milliseconds
• delayMicroseconds(us)
✔ Pauses for a few microseconds
Module 4 – Building IoT with Galileo/Arduino 20
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Summary
• Arduino Integrated Development Environment (IDE)
• Steps in Arduino Programming
• Using Arduino
• Adding an External LED to pin 13
• Toolbar
• Arduino Code
• Terminology
• Basic Hardware Functions
• Basic Software Functions
• Some Other Basic Functions
Module 4 – Building IoT with Galileo/Arduino 21
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Try Yourself
• Is Arduino IDE open source?
• Determine the best Arduino IDE.
• Find the language used by Arduino IDE.
• Does Arduino IDE use Java?
• Can I use Visual Studio for Arduino?
Module 4 – Building IoT with Galileo/Arduino 22
Session 3 - Arduino IDE 18IT067 – Internet of Things
Arduino IDE
Try Yourself
• Find the 8 words related to Arduino IDE
E C R U O S N E P O
A V L A T I G I D B
S K E T C H F T M G
G N F R P J E B F I
D O K D I Q D K S U
K G L C N F Q V P W
A J D A H L Y L R H
L H B M N R O U T C
D E L A Y A P C G D
C F K I D J G B J A
Module 4 – Building IoT with Galileo/Arduino 23
Next Session......
Introduction to Arduino Shields