Arduino
Programming Things
Team Emertxe
Introduction
Arduino
Introduction – What?
An open-source electronics platform based on
easy-to-use hardware and software
Source: www.arduino.cc
Arduino
Introduction – Why?
●
Inexpensive
●
Cross-platform
●
Simple, clear programming environment
●
Open source and extensible software
●
Open source and extensible hardware
Arduino
Introduction – How do I use?
●
Code online on the Arduino Web Editor
– To use the online IDE simply follow these instructions.
Remember that boards work out-of-the-box on the
Web Editor, no need to install anything.
●
Install the Arduino Desktop IDE
Arduino
Introduction – How do I use?
●
Install the Arduino Desktop IDE
– To get step-by-step instructions select one of the
following link accordingly to your operating system.
●
Windows
●
Mac OS X
●
Linux
●
Portable IDE (Windows and Linux)
Setup
Arduino
Setup – Workspace Creation
/
home
Open your favorite terminal and
run the following commands
user
ECIP user@user:~] cd # Make sure you are in home directory
user@user:~] pwd
4-ArduinoProgramming /home/user
user@user:~] mkdir -p ECIP/4-ArduinoProgramming
user@user:~] cd ECIP/4-ArduinoProgramming
Datasheets user@user:4-ArduinoProgramming]
user@user:4-ArduinoProgramming] mkdir Datasheets
user@user:4-ArduinoProgramming] mkdir References
References user@user:4-ArduinoProgramming] mkdir Schematics
user@user:4-ArduinoProgramming] mkdir Sketches
Schematics user@user:4-ArduinoProgramming] mkdir Sources
user@user:4-ArduinoProgramming] ls
Datasheets References Schematics Sketches Sources
Sketches user@user:4-ArduinoProgramming]
Sources
Arduino
Setup – Download
●
Click the below icon and download the latest version of
IDE, Make sure you select the correct Linux Version based
on your system
CLICK
ME
●
Assuming you have downloaded the file in the Download
directory, proceed with the installation steps mentioned
in the next slide
Arduino
Setup – Installation
user@user:4-ArduinoProgramming] ls
Datasheets References Schematics Sketches Sources
user@user:4-ArduinoProgramming] cd Sources
user@user:Sources] mv ~/Downloads/arduino-*.tar.xz .
user@user:Sources] tar xvf arduino-*.tar.xz
user@user:Sources] cd arduino-*
user@user:arduino-<version>] chmod +x install.sh
user@user:arduino-<version>] ./install.sh
Adding desktop shortcut, menu item and file associations for Arduino IDE... done!
user@user:arduino-<version>]
●
In case if you want to uninstall!, you may follow the
below step
user@user:arduino-<version>] chmod +x uninstall.sh
user@user:arduino-<version>] ./uninstall.sh
Removing desktop shortcut and menu item for Arduino IDE... done!
user@user:arduino-<version>]
IDE Overview
Arduino
IDE
Sketch Name with IDE Version
Date
Serial Monitor
Menu Bar Tab Functions
Verify Sketch
Upload Sketch to
Board
New Sketch Editor
Open Sketch
Save Sketch
Output Window
Cursor Position Board / Port Info
Arduino
Sketch - Default
All one time initialization goes
here. For example,
●
Configuration of DDR register
●
Serial port setup etc.,
The application code, which
should loop forever should be
put here
Arduino
Sketch – Save As
Arduino
Sketch – Save As
Arduino
Sketch – Save As
Saved Sketch as
Board Architecture
Arduino
Hardware Architecture
●
There are different varieties of boards, modules and
shields available
●
Can be used for different complexity levels like basic
sensor node with non OS firmware to an IoT gateway
based on embedded Linux
●
Few types of boards and its architectures are mentioned
in next slides
Arduino
Hardware Architecture - UNO
USB
Interface
ATMEGA328P
GPIO
Arduino
Hardware Architecture – UNO - Board
Arduino
Hardware Architecture - TIAN
DDR2 Wifi
64 MB
Ethernet
SPI Flash 10/100/1000
16 MB Atheros
AR9342
USB 2.0
eMMC
DEBUG USB HUB
4 GB
Bluetooth
SAMD21G18
GPIO
Arduino
Hardware Architecture – TIAN - Board
Arduino
Hardware Architecture – Shield - Motor
Arduino
Hardware Architecture – Shield - Relay
Arduino
Hardware Architecture
●
So as summary we lots of open source hardware option to
pick upon
●
As part this module, we would be concentrating on
NodeMCU, based on ESP8266 Wi-Fi Module
The First Sketch
Arduino
The First Sketch
●
Well, as general approach, write that first code
(irrespective of the hardware you work on), which gives
you the confidence that you are on the right path.
●
So, identify the simplest possible interface which can be
made to work with lesser overhead, which helps us to
verify that our,
– Hardware is working
– Toolchain setup is working
– Connectivity between the host and target is established
and so on.
Arduino
The First Sketch
●
It is good to know, what your target board is?, what it
contains? by its architecture
●
Board architecture generally gives you overview about
your board and its peripheral interfaces
●
In our case, as already mentioned we will be using
NodeMCU whose architecture is given in the next slide
Arduino
The First Sketch – NodeMCU - Architecture
USB
Interface ESP32 LED
BLE Wi-Fi
GPIOs SWITCH
Arduino
The First Sketch – NodeMCU – Module
Arduino
The First Sketch
●
From the NodeMCU’s
architecture, we come to
know about a built-in LED!, so
why not start with it?
●
Well, if you have a bit of
microcontroller programming
experience, you would
certainly ask a question on
where and how the LED is
connected?
Built-in LED ●
The board schematic has this
answer.
Arduino
The First Sketch – NodeMCU – Schematic (Part)
●
The LED is connected to
GPIO2
●
Its a sinking circuit (O to
VDD3V3
glow)
●
With these basic information,
LED1
it should possible to write our
first sketch
GPIO2 ●
Please refer the next slide to
proceed further
Arduino
The First Sketch – I/O Configuration
●
Almost all the modern controllers have multiple mode on
a port pin by design
●
We need to set the right mode before we can write our
application!
●
The LED is connected at GPIO2 which has to be set as
Output Pin
●
Would like to recall that, The Arduino platform is very
popular because of its rich library functions, which make
it easy to program embedded devices
●
So we need the right set of libraries configured in our IDE
for the target board we are using
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
Arduino
The First Sketch – Libraries
ECIP/4-ArduinoProgramming/Sketches
https://dl.espressif.com/dl/package_esp32_index.json
https://dl.espressif.com/dl/package_esp32_index.json
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
Arduino
The First Sketch – Libraries
●
If you have followed all the steps upto the previous slide
then, the library for ESP32 would have been installed
●
The next step would be selecting your target board
●
Make sure you have connected the Target board before
proceeding further
●
Save the existing sketch as led_heartbeat (You may the
follow the steps given in IDE introduction)
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Host and Target Interface
Arduino
The First Sketch – Coding
●
Now that everything is ready let’s move toward
programming the target board
●
From all the information we have in previous slides, we
can use the LED blinky example from the arduino website
as is!!
●
Please refer the next slide
Arduino
The First Sketch – Code
Arduino
The First Sketch – Compile
Arduino
The First Sketch – Compile
Arduino
The First Sketch – Compile
Arduino
The First Sketch – Upload
Arduino
The First Sketch – Upload
Arduino
The First Sketch – Upload
Arduino
The First Sketch – Output
Blinking LED
Arduino
The First Sketch – Summary
●
So from our first sketch we come to know that there are
some built-in functions or classes to be used!
●
The next topic covers some of the most commonly used
functions or classes in Arduino
Thank You