A Complete Beginners Guide On Learning To Engineer and Program Arduino
A Complete Beginners Guide On Learning To Engineer and Program Arduino
A Complete Beginners Guide On Learning To Engineer and Program Arduino
Jason Hamilton
© Copyright 2020 by Jason Hamilton
All rights reserved.
The follow eBook is reproduced below with the goal of providing
information that is as accurate and reliable as possible. Regardless,
purchasing this eBook can be seen as consent to the fact that both the
publisher and the author of this book are in no way experts on the topics
discussed within and that any recommendations or suggestions that are made
herein are for entertainment purposes only. Professionals should be consulted
as needed prior to undertaking any of the action endorsed herein.
This declaration is deemed fair and valid by both the American Bar
Association and the Committee of Publishers Association and is legally
binding throughout the United States.
Furthermore, the transmission, duplication or reproduction of any of the
following work including specific information will be considered an illegal
act irrespective of if it is done electronically or in print. This extends to
creating a secondary or tertiary copy of the work or a recorded copy and is
only allowed with express written consent from the Publisher. All additional
right reserved.
The information in the following pages is broadly considered to be a
truthful and accurate account of facts and as such any inattention, use or
misuse of the information in question by the reader will render any resulting
actions solely under their purview. There are no scenarios in which the
publisher or the original author of this work can be in any fashion deemed
liable for any hardship or damages that may befall them after undertaking
information described herein.
Table of Contents
Introduction
Chapter One: Introducing Arduino
Chapter Two: Arduino IDE
Chapter Three: Arduino Boards
Chapter Four: Recent Information on Arduino Usage
Chapter Five: Arduino Coding Principles
Chapter Six: Arduino C Data
Chapter Seven: 10 Great Beginners’ Projects with Arduino
Chapter Eight: Fixing Common Arduino Troubleshooting Problems
Final Words
Introduction
Are you looking for a detailed and precise book on learning Arduino?
Let’s cut the loose ends of wiring/programming and learn what you need
to know.
An up to date practise of Arduino is found throughout this novella. You
will Explore the core requirements of Arduino. Learn the history behind it
and learn how to use Arduino boards in order to make your own projects.
Jason Hamilton walks you through the basics of Arduino, he explains the
electrical engineering, human-computer interactions and the complex data
programming codes that are required. If you get stuck, we have you covered
in chapter eight.
Whether you are a beginner or an intermediate with Arduino. Jason
demonstrates how to navigate your way around Arduino Programming and
boards with the use of detailed knowledge and pictures. Delve into the
depths of this novella and keep it handy as you are building/ programming
your Arduino project. There are many codes and sequences you will need to
follow in order to complete your project. So, this will essentially become
your handbook.
This book offers an in-depth introduction into using Arduino and gives a
step by step guide on what to look for and what to do in building 10 beginner
projects that will make you ecstatic about.
Well what are you waiting for?... Start your journey to your new beloved
hobby. Purchase this book and you’ll obtain the skills and knowledge
required to build and program your very own micro controlled prototypes or
projects!
Chapter One:
Introducing Arduino
What is Arduino?
Arduino is an electronics system used to create interactive objects for
human comfort. It is a mini computer with hardware and software
components that is capable of working online or offline. Its software
component, the Arduino IDE, can be downloaded from the Arduino website,
and it comes with several easy-to-use features and capabilities. The Arduino
IDE (Integrated Development Environment) is used to initiate commands for
the hardware component, development board, and runs fine on all operating
systems—a situation that made it a cross-platform microcontroller.
The development board is a programmable, ready-to-use circuit designed
to take coded instructions from the IDE and affect prompt execution. In
executing required actions, the Arduino board works closely with the
connected sensors and input devices, being tools used to control electronics
and build interactive objects. The board uses these tools to read inputs,
control outputs, and execute desired actions.
Arduino is an open-source programmable platform, meaning that it
enjoys program flexibility. Its programs move to the Arduino development
board via a USB cable. This board is capable of performing several tasks in
the physical world. It can sense and control objects, respond to sensors and
inputs, and handle all sorts of outputs, including LEDs and displays. Its
ability to create interactive hardware projects and breathe life into amazing
project imaginations have made it the popular choice for people who work in
both professional and hobby industries. Written-and-run IDE programs are
commonly known as sketch instruction codes that the Arduino board uses to
build hardware projects. Programming languages are used to code
instructions for the board to create interactive objects.
Arduino—being a microcontroller—comes with an integrated circuit that
records coded instructions and has all the required peripherals to connect
input and output components of regular personal computers. Its serial
communication peripheral means that Arduino can work well on personal
computers. Arduino comes with 14 digital pins numbered from 0 to 13. These
pins can run both input and output operations, depending on their setup. They
are designed to read voltage as high or low when set as inputs but will go a
step further to apply voltage when set as outputs. These pins aid serial
communication between Arduino and other electronics, especially when new
instruction codes are uploaded. Digital badges are to be used only for serial
interface, or they may soon run out.
Like many other microcontrollers, Arduino works mainly via its input
and exit interfaces. The input interface can be connected directly to the
computer through ports or linked through its peripherals and can aid the
transfer of data from the computer to the Arduino board, where it would be
processed. The exit interface picks up the job once the data gets to the
Arduino board.
Why Arduino?
Already, Arduino has become the popular choice of many people in the
professional and hobby industries, and its acceptance is growing daily thanks
to fantastic hardware projects that people build with it. The pertinent question
on the lips of many people is: what makes Arduino unique or different from
other microcontrollers? In answering this question, a co-founder of Arduino
Massimo Banzi highlighted the reasons why Arduino has remained the
choice of many (Louis, 2016):
1. Active User Community: Arduino offers a free interactive
community for its teeming users to share ideas, experiences, and get
their everyday troubleshooting issues resolved. Users of similar
products now have the opportunity to share thoughts via posted
conversations.
2. User-friendly Features: Arduino is a user-friendly microcontroller
capable of creating hardware devices that could interact with the
environment through sensors and actuators. Its trouble-free features
have made it the go-to microcontroller for creating amazing hardware
projects.
3. Inexpensive Hardware: Arduino is an open-source, programmable
microcontroller. Users do not have to purchase hardware designs or
software; only the board or needed parts need to be purchased. You
can download the hardware designs and the software online free of
charge from www.arduino.cc, the official website of Arduino.
4. The versatility of the Arduino Board: One thing that makes the
Arduino board unique is its versatility. It is easy to use and usable
everywhere. It can function as a programmer, and its USB cable is
strong enough to moderate its power requirements.
5. Cross-platform: Users love Arduino because it can work on popular
platforms such as Mac, Linux, and Windows operating systems,
unlike some microcontrollers that only run on Windows. The
Arduino user community is also always growing.
Regular Users of Arduino
Arduino was a fast prototyping tool for students who never had
electronics and programming backgrounds. People had hardly been using it
before new needs and challenges began to emerge. Still, Arduino went ahead
to adjust its mode of operations in a desperate bid to address emerging needs.
Users too began to create hardware projects that were capable of meeting
public needs, but this would not have been possible if Arduino boards and
software were not open source. What was initially intended for students has
now been used to create fantastic hardware objects in all areas of human
endeavour. Regular users of Arduino include teachers, students, electricians,
designers, architects, musicians, and artists.
Teachers and students use it to design low-cost, scientific teaching aids
and test physics and chemistry principles. It is also a go-to centre for those
who have a passion for programming and robotics.
Electricians often use it for prototyping their products and showcasing
their ideas. They can also use it to build amazing projects like solar
streetlight, home automation, industrial appliance control, cable fault
detection, and obstacle avoidance.
Designers and architects use Arduino to design cell walls, dynamic
environments, and other interactive prototypes, while musicians and artists
can experiment with their new musical instruments on Arduino.
Arduino is a user-friendly learning tool that can be used by everyone.
History of Arduino
The need to design a fast prototyping tool for students who never had
electronics and programming backgrounds led to the production of Arduino
in 2005 at the Interactive Design Institute in Ivrea, Italy. Right there in a
classroom, Hernando Barragan, a Colombian student of the institute,
postulated a hardware thesis for the production of a wiring design. His title
then was Arduino—La rivoluzione dell'open hardware, which can be
translated to Arduino—'The Revolution of Open Hardware’. Massimo Banzi
and David Cuartielles adopted this thesis to design a pocket-friendly
programmable device now known as Arduino.
Banzi was a software architect before the institute recruited him as an
associate professor in 2002 to teach students new ways of doing physical
computing. He could not showcase his amazing ideas because he had issues
of budget and limited class time. His inability to work on his amazing ideas
made him use BASIC Stamp—the popular microcontroller of the time. Banzi
had issues with the Stamp because its computing power was too small to run
some of his students' conceptualized projects, and it was costly. He had a
viable interest in a microcontroller that would be compatible with Macintosh
computers because designers hardly use other computers at the institute.
Meanwhile, Processing—a designed user-friendly programming
language—had caught the attention of Banzi. The programming language
was so good that even amateur programmers could use it easily to develop
beautiful and complex visualizations. Banzi planned to create a similar
program, but one that could code a microcontroller, not just graphics
displayed on a screen. It was Hernando who took the first step to create
something similar to processing. His design—a user-friendly and ready-to-
use circuit board—became known as Wiring and was a promising project of
the time; however, Banzi had bigger dreams. He wanted a microcontroller
that was far cheaper and easier to use, a feat he achieved in 2005 when he
successfully built the prototype board.
So, working on the wiring thesis of Hernando Barragan, Massimo Banzi,
and David Cuartielles created Arduino to aid the creation of fantastic
hardware design projects. David Mellis later developed the Arduino software
before Gianluca Martino and Tom Igoe joined the project. Already
considered as the founders of Arduino, the five developers worked to produce
an easy-to-use and less expensive microcontroller that could connect relays,
motors, sensors, and other devices.
Advantages of Arduino
Consider some of the advantages of using Arduino below:
1. Menu Bar: The menu bar lies at the top of the software. A click
on this bar will show five options.
● File: Select this option if you want to program code in a new window
or open one already stored on your system.
● Edit: Here, you can modify the font used for the coding exercise and
copy and paste it as you want.
● Sketch: Use this to compile and program the code.
● Tools: Use this to test your projects and burn it to the microcontroller
in the Arduino board.
● Help: Tap this if you need help with running your projects via the
software.
Right there under the Menu tab are six buttons. Users need to understand
these buttons and how to use them.
● Check mark: Mark is a circular button used for code verification. Do
click the button once you finish writing your code.
● Arrow key: Use the arrow key to upload or transfer the written code
to the board.
● Dotted paper: Use this paper to create a new file.
● Upward arrow: Use this arrow only when you want to open an
existing project.
● Downward arrow: Click the arrow when you want to save your
code.
● Serial Monitor: The serial monitor lies at the top-right-hand corner
of the Arduino IDE. Use it to debug written codes, send and receive
serial data.
2. Text Editor: Just below the Menu bar, you will see the screen
for the text editor, where you can program your code.
3. Output Pane: The output pane occupies the bottom part of the
text editor, and it shows the compilation status of the code you
are running, the memory it has used, and errors already
encountered. You must fix these errors before you can send your
code to the board.
Digital pins on the Arduino board can run input and output functions, but
this depends on the commands you give them via the software. Although
digital read controls make Arduino pins run input functions, digital write
commands will instruct these pins to run output functions. Use the commands
as they appear here because they are case sensitive.
Arduino C—like the regular C languages used in programming other
system microcontrollers—works fine, but other amazing libraries could
execute specific functions on the Arduino board. Click the sketch button to
add these extra functions. Click the Menu bar >Include Library >Add the
libraries you want. It is as simple as that.
The Arduino IDE comes with most of these libraries, but there are other
external sources where you can download them too. However, do make sure
that you select your board, ports, and operating system correctly before you
get your code uploaded, and these steps will aid your progress.
1. Setup: Right there in the setup section of the Arduino sketch lies
the setup () function. Use it to prompt the start of a sketch,
variables, pin modes, and libraries. It handles sensor calibration
and other tasks that are performed one at a time. The function
can only run when the Arduino board goes through a reset. It
also shows the input and output interactions of the board with the
serial monitor.
2. Loop: The input, which is the first part of the logic (if)—sets the
tone of action for the loop () function—Loop is used to aid the
smooth operation of the Arduino circuit on the computer. The
loop ensures that programs run consecutively, thereby giving the
system ample opportunity to respond to each application.
3. Manipulative Data: Manipulative data aids the transformation
of data to forms that are suitable for calculations. For example,
the 0-1023 reading of the Analog Read () command can cover
the range of 0-255, which is ideal for the Pulse-width modulation
(PWM).
4. Output: Output is the second part (then) of the logic, and it
centres mainly on the manipulative data arrived at by the system.
Program your Arduino IDE with these simple steps.
5. Reset Button: Press the reset button when you want to reset the
board or restart a code on the Arduino. Use it to test the
functionality of codes multiple times, especially when those
codes often fail to repeat.
6. Power LED Indicator: Each Arduino board has a tiny power
LED indicator that lights up the board when it has been plugged
into a power source.
7. Main IC: Also known as the brain of the circuit, the main IC is
black and comes with metal legs, but it depends on the type of
board one is using. Users need to know their board and IC type,
or they may have issues uploading new programs via their
Arduino software.
8. Voltage Regulator: Users do not have to interact with the
voltage regulator. It is designed to regulate the voltage that gets
into the board.
Popular Arduino Boards
What is it?
Little was known about the C programming language until 1983, when
the X3J11 committee was formed by the American National Standard
Institute (ANSI) to determine the acceptability or otherwise of the
programming language. The language was accepted by the committee when
the latter completed its analysis in 1989, and the International Organization
for Standardization (ISO) also cast their support for the programming
language. After that, the C programming language became known as “ANSI
C” or “ISO C.” Arduino C does not come with all the features of the standard
C programming language.
Arduino C Data Types
Arduino C is quite similar to standard C data types. The compiler needs
to know the kind of data that will go with every defined variable, so it can
dedicate the right byte of memory for the variable. Value and reference are
the two primary forms of data. There is a range of values for every variable
defined with the value data type. Here is a tabular list of Arduino C data
types, according to Purdum (2012, p. 37).
2. Text-to-Speech Converter
Arduino text-to-speech converter aids the conversion of text to spoken
speech via an electronic device. Large organizations and public transportation
companies use the tool often to interact or pass information to their
customers.
Components Required
● Arduino Uno
● Connecting Wires
● 10K Resistor
● An Amplifier Circuit
● A Speaker
Procedure
Connect 10K resistor to digital three pins of your Arduino. Plug power
supply to the amplifier circuit and connect the Arduino board to the circuit
before you connect the speaker. Add Arduino TTS library on the IDE. To do
this, open Sketch >Include Library >Manage Libraries and add the TTS
library. Type Talkie in the Search bar to install the library.
Include some headers and convert digital pin 3 to output pin by writing
this command in Sketch.
#include “Talkie.h”
#include “Vocab_US_Large.h”
#include “Vocab_Special.h”
Make setup () empty and activate loop () with these commands
void setup () {
}
void loop () {
voice.say (spPAUSE2);
voice.say (sp2_DANGER);
voice.say (sp2_DANGER);
voice.say (sp3_STORM);
voice.say (sp3_IN);
voice.say (sp3_THE);
voice.say (sp3_NORTH);
}
Upload Sketch to the Arduino board
3. Weather Station
This simple weather station can be powered with the DHT11 sensor and
Arduino to sense humidity and temperature and provide results via its LCD
Display. DHT11—the humidity and temperature sensor—may have three or
four pins, depending on the type one purchases in the market. You can use
the two DHT11 sensor types for this project.
Components Required
● DHT11
● 16×2 12C LCD Display
● Arduino Uno
● 8 Male or Female Jumper Wires
● Connect DHT11 to the Arduino board
Procedure
Use the connection sample below if you are using a DHT11 sensor with
four pins.
DHT11 Arduino Uno
VCC 3.3V
OUT Pin4 (Digital)
GND GND
NC --
Ensure you connect a 10K Ohm resistor between the DHT11 VCC and
the Out Pin.
Use the sample below to connect DHT11 with three pins.
DHT11 Arduino Uno
VCC 3.3V
OUT Pin 4 (Digital)
GND GND
Connect the LCD Display to Arduino
The LCD consists of SCL and SDA signals. Although SCL represents
the clock signal, the SDA shows the data signals. There is a current bus
master in the LCD that generates the clock signal, but specific forces may
prevent the bus master from creating the required data. Consider the sample
below when connecting the LCD Display.
LCD Display Arduino
GND GND
VCC 5V
SDA A4
SCL A5
Create the Code
Ensure the DHT11 and 12C LCD libraries are downloaded and
included. The DHT11 library is available for download
on https://mega.nz/file/4XZ2CaAT#AhhLEoCUN7XMrgzAuAtFFUA9BucotUSD3-
to4qEJr2c, and you can download the 12C LCD from
https://drive.google.com/file/d/1edC9yXdDUFs59nwzDIsCZW2gma3xkgBQ/view
Write the command below in the Sketch once you have included the libraries.
#include <dht.h>
#include <Wire.h>
#include <Liquid Crystal_12C.h>
LiquidCrystal_12C lcd(0×27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
dht DHT; #define DHT11_PIN 4
void setup(){
lcd.begin(16, 2); }
void loop () {
int d = DHT.read 11 (DHT11_PIN);
lcd.setCursor(0,0);
lcd.print(“Temp: ”);
lcd.print(DHT.temperature);
lcd.print((char)223);
lcd.print(“C”);
lcd.setCursor(0, 1);
lcd.print(“Humidity: ”);
lcd.print(DHT.humidity);
lcd.print(“%”);
delay(1000);
}
Upload Sketch to the Arduino board.
1. Be sure the target board is not different from the one selected in
the Arduino IDE
2. Check whether the sketch size is within the capacity of the board
3. Adjust the power supply and make it stable.
Sketch Too Large
If the flash memory of the board is smaller than the size of the sketch,
this troubleshooting problem will pop up. For example, this warning will pop
up when one tries to upload a plan that is above 32KB on the Arduino Uno.
This board comes with a 32KB flash memory, out of which 2KB has gone for
the Arduino bootloader. Since the size of the sketch causes the problem, find
a way to reduce the amount of space the plan currently occupies. Use the tips
below to address the issue.