Arduino Training Course Outline With Lecture
Arduino Training Course Outline With Lecture
I. Flow Charting
a. Signs, Symbols and Pseudo Coding
Flow Charts
A flowchart is a type of diagram that represents a workflow or process. A flowchart can also be
defined as a diagrammatic representation of an algorithm, a step-by-step approach to solving a task.
The flowchart shows the steps as boxes of various kinds, and their order by connecting the boxes with
arrows. This diagrammatic representation illustrates a solution model to a given problem. Flowcharts
are used in analyzing, designing, documenting or managing a process or program in various fields.
If you have to break up a chart, you can use a connector block symbol which is a circle. In the chart
above there is a circle with the letter "A" at the bottom left of the chart. This signifies that control
should be transferred to another point on the chart that has a circle with the letter "A." That point is
located at the upper right corner of the chart. Using connectors allows you to fit charts to the paper
more easily. The circle can be used to reference a point on the same page or on another page.
Connector Block
You can also use the off page connector shape shown below. The circle and the off page connector
are equivalent. Inside the circle you can use either letters or numbers. For off page references you
should use the page number.
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino
boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it
into an output - activating a motor, turning on an LED, publishing something online. You can tell your
board what to do by sending a set of instructions to the microcontroller on the board. To do so you use
the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on
Processing.
Over the years Arduino has been the brain of thousands of projects, from everyday objects to complex
scientific instruments. A worldwide community of makers - students, hobbyists, artists, programmers,
and professionals - has gathered around this open-source platform, their contributions have added up
to an incredible amount of accessible knowledge that can be of great help to novices and experts alike.
Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping, aimed at
students without a background in electronics and programming. As soon as it reached a wider
community, the Arduino board started changing to adapt to new needs and challenges, differentiating
its offer from simple 8-bit boards to products for IoT applications, wearable, 3D printing, and embedded
environments. All Arduino boards are completely open-source, empowering users to build them
independently and eventually adapt them to their particular needs. The software, too, is open-source,
and it is growing through the contributions of users worldwide.
b. Why Arduino?
Thanks to its simple and accessible user experience, Arduino has been used in thousands of different
projects and applications. The Arduino software is easy-to-use for beginners, yet flexible enough for
advanced users. It runs on Mac, Windows, and Linux. Teachers and students use it to build low cost
scientific instruments, to prove chemistry and physics principles, or to get started with programming
and robotics. Designers and architects build interactive prototypes, musicians and artists use it for
installations and to experiment with new musical instruments. Makers, of course, use it to build many of
the projects exhibited at the Maker Faire, for example. Arduino is a key tool to learn new things. Anyone
- children, hobbyists, artists, programmers - can start tinkering just following the step by step
instructions of a kit, or sharing ideas online with other members of the Arduino community.
There are many other microcontrollers and microcontroller platforms available for physical computing.
Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many others offer similar
functionality. All of these tools take the messy details of microcontroller programming and wrap it up in
an easy-to-use package. Arduino also simplifies the process of working with microcontrollers, but it
offers some advantage for teachers, students, and interested amateurs over other systems:
Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms.
The least expensive version of the Arduino module can be assembled by hand, and even the pre-
assembled Arduino modules cost less than $50
Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux operating
systems. Most microcontroller systems are limited to Windows.
Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for beginners, yet
flexible enough for advanced users to take advantage of as well. For teachers, it's conveniently based on
the Processing programming environment, so students learning to program in that environment will be
familiar with how the Arduino IDE works.
Open source and extensible software - The Arduino software is published as open source tools, available
for extension by experienced programmers. The language can be expanded through C++ libraries, and
people wanting to understand the technical details can make the leap from Arduino to the AVR C
programming language on which it's based. Similarly, you can add AVR-C code directly into your Arduino
programs if you want to.
Open source and extensible hardware - The plans of the Arduino boards are published under a Creative
Commons license, so experienced circuit designers can make their own version of the module, extending
it and improving it. Even relatively inexperienced users can build the breadboard version of the module
in order to understand how it works and save money.
Arduino/Genuino boards senses the environment by receiving inputs from many sensors, and affects
their surroundings by controlling lights, motors, and other actuators. Arduino/Genuino boards are the
microcontroller development platform that will be at the heart of your projects. When making
something you will be building the circuits and interfaces for interaction, and telling the microcontroller
how to interface with other components. Here the anatomy of Arduino/Genuino Uno.
1. Digital pins Use these pins with digitalRead(), digitalWrite(), and analogWrite(). analogWrite() works
only on the pins with the PWM symbol.
2. Pin 13 LED The only actuator built-in to your board. Besides being a handy target for your first blink
sketch, this LED is very useful for debugging.
3. Power LED Indicates that your Genuino is receiving power. Useful for debugging.
6. GND and 5V pins Use these pins to provide +5V power and ground to your circuits.
7. Power connector This is how you power your Genuino when it’s not plugged into a USB port for
power. Can accept voltages between 7-12V.
8. TX and RX LEDs These LEDs indicate communication between your Genuino and your computer.
Expect them to flicker rapidly during sketch upload as well as during serial communication. Useful for
debugging.
9. USB port Used for powering your Genuino Uno, uploading your sketches to your Genuino, and for
communicating with your Genuino sketch (via Serial. println() etc.).
Pin Modes – pins are automatically declared as input pins by default. However, you can change it using
the code pinMode(pin,Mode). Different modes are as follows:
1. OUTPUT – pins configured as output produce either HIGH (5v) or LOW (0v) using the code
digitalWrite(pin,STATE)
2. INPUT – pins configured as input read either HIGH (3.3-5V) or LOW (0V) using the code
digitalRead(pin)
3. INPUT_PULLUP – pins configured as input_pullup works just like an input pins except that the
value is always high unless connected to GND. Mostly used in push buttons.
Analog Pins
Analog pins can also work just the same as digital output pins. However, analog pins are normally used
as analog input pins to read voltage inputs from an analog to digital converter which has 10-bit
resolution and returns integers form 0-1023 using the code analogRead(pin). Analog pins are added
letter A from their pin assignment. (ex A0,A1,A2…).
iii. PWM
Pulse Width Modulation, or PWM, 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. The duration of "on time" is called the pulse
width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off
pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0
and 5v controlling the brightness of the LED.
In the graphic below, the green lines represent a regular time period. This duration or period is the
inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the
green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that
analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on
half the time) for example.
iv. Memory
There are three pools of memory in the microcontroller used on avr-based Arduino boards:
2. SRAM (static random access memory) is where the sketch creates and manipulates variables
when it runs.
3. EEPROM is memory space that programmers can use to store long-term information.
Flash memory and EEPROM memory are non-volatile (the information persists after the power is turned
off). SRAM is volatile and will be lost when the power is cycled.
Summary:
Arduino Uno and Nano are basically just the same with minor differences with size as the most
relevant. Arduino Mega can be considered as an upgrade for Uno/Nano when it comes to pin and
memory capacity. All are programmable using the same Arduino IDE and language.
The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board.
It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing
and other open-source software.
Sketch_oct30a – File name created by Arduino when you create new file. Will be changed depending on
the file name when saved.
Dropdown Menus
File
Open Recent – To save time locating your recently open files (10).
Sketch
Help
*Prerequisites
void setup() {
void loop() {
Sketch
A sketch is the name that Arduino uses for a program. It's the unit of code that is uploaded to and
run on an Arduino board.
Comments
Everything between the /* and */ is ignored by the Arduino when it runs the sketch. There's
another style for short, single-line comments. These start with // and continue to the end of the line.
Variables
A variable is a place for storing a piece of data. It has a name, a type, and a value. For example,
the line from the Blink sketch above declares a variable with the name ledPin, the type int, and an initial
value of 13. It's being used to indicate which Arduino pin the LED is connected to. Every time the
name ledPin appears in the code, its value will be retrieved. In this case, the person writing the program
could have chosen not to bother creating the ledPin variable and instead have simply written 13
everywhere they needed to specify a pin number. The advantage of using a variable is that it's easier to
move the LED to a different pin: you only need to edit the one line that assigns the initial value to the
variable. Often, however, the value of a variable will change while the sketch runs. For example, you could
store the value read from an input into a variable.
Functions
A function (otherwise known as a procedure or sub-routine) is a named piece of code that can be
used from elsewhere in a sketch. The first line provides information about the function, like its name,
"setup". The text before and after the name specify its return type and parameters: these will be explained
later. The code between the { and } is called the body of the function: what the function does.
void setup()
{
pinMode(ledPin, OUTPUT); //sets the digital pin as output
}
For controlling the Arduino board and performing computations.
Delay
The delay() causes the Arduino to wait for the specified number of milliseconds before continuing
on to the next line. There are 1000 milliseconds in a second, so the line: delay(1000); creates a delay of
one second.
i. Examples
1. Open blink from examples and save a copy into desktop.
2. Upload the blink code on different types of Arduino boards.
3. Manipulate the blink code to run once and in loop.
4. Edit blink frequency.
b. Data types, literals and variables (Arduino.cc/references/en)
Variables
i. Examples
1. Print different variables in serial monitor
2. Use comments and global variables
c. Arithmetic Operators
Structure
i. Examples
1. Test PEMDAS
2. Simplify code using compound operators
d. Conditional Statements
i. Examples
1. Compare variables and print true or false
2. Use if/else/if else
3. Use button to control serial monitor output
e. Logical Operators
i. Examples
1. Boolean logic
2. Switch led using one button
f. Loops
i. Example
1. Using while control dimming of led (0-256)
2. Using break turn off light while pressed
3. Using continue to hold brightness.
a. Challenge – timely press button while led is off
g. Activities
i. Convert the previous flow charts into Arduino sketch.