0% found this document useful (0 votes)
13 views56 pages

Arduino Workshop Slides

This document is an introduction to Arduino programming and its ecosystem, detailing the components of an Arduino, its capabilities, and fundamental electronics concepts. It covers programming basics, including variables, data types, conditional statements, and functions, along with practical tasks for using the Arduino IDE. The workshop encourages hands-on learning through exercises that involve measuring and displaying data from various sensors.

Uploaded by

devenw666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views56 pages

Arduino Workshop Slides

This document is an introduction to Arduino programming and its ecosystem, detailing the components of an Arduino, its capabilities, and fundamental electronics concepts. It covers programming basics, including variables, data types, conditional statements, and functions, along with practical tasks for using the Arduino IDE. The workshop encourages hands-on learning through exercises that involve measuring and displaying data from various sensors.

Uploaded by

devenw666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

ARDUINO

WORKSHOP
An Introduction to
Programming and Arduino

Sam Knox
Keith Anderson
WHAT IS AN
ARDUINO?
It's a computer.
WHAT IS AN
ARDUINO?
Like a desktop/laptop, it has:
A CPU (Central Processing Unit)
Plugs to connect components
Ability to run programs
The Arduino Ecosystem

Arduino is the brand name of


a family of microcontroller
boards
They come in all shapes and
sizes
There's a large community of
hobbyists and professionals
using the Arduino platform
There's a large number of
compatible attachments and
components
WHAT CAN WE
DO WITH ONE?
Make a heartbeat sensor
Control RGB lights
Make a flight controller for a drone
WHAT CAN WE
DO WITH ONE?
Build a Bluetooth-controlled Nerf turret
Build a system monitor
for your vehicle

What are some useful things that


we could measure and display?
Build a system monitor
for your vehicle

Speed
Battery Temperature
Motor Temperature
GPS Location
Battery Voltage
Battery Current
Lap Timing
Efficiency
EVolocity Rules
Your Arduino Kit

Check that your kit has these


items:
Arduino Nano (In a bag)
NTC Thermistor
USB C Cable
Barrel Jack Terminal Adapter
LCD Screen
EVolocity Arduino Motherboard (AMB)
ELECTRONICS
FUNDAMENTALS
Electricity
Ohm's Law
What is electricity?
What is electricity?

Flow of electrons
What is electricity?

Flow of electrons A form of energy


OHM'S LAW

Voltage(V) = Current(I) x Resistance(R)

More simply V=IxR

Describes the relationship between electrical properties


PROGRAMMING
FUNDAMENTALS
Analog vs Digital
Variables & Data Types
Conditionals
Functions
Analog vs Digital
We can measure the voltage at any point of an analog signal
and have an infinite number of possible values (depending
on our measuring equipment)
A digital signal will only ever measure one of two values,
AKA binary
Digital Signals
We can read:
On/Off
High/Low
1/0
Digital Signals
We can use this principle to transmit messages:
We communicate with binary digits or bits
8 bits make a byte

How many bits


in a gigabyte?
Digital Signals
So if we have two devices programmed to understand one
another’s bit sequences, then they can talk to each other.

For example, we tell both devices that:


01101011 = launch
01101010 = land
Then we send the byte from device 1 to device 2 and have it
react accordingly.
Variables & Data Types

Variables are numbers that we identify using a name.

They can change, hence variable.

We declare (or initialise) them like so:

int my_integer = 1;

Now the variable "my_integer" can be used throughout the program by


typing its name.
Variables & Data Types

Variables always have a “data type”, which tells the Arduino what
kind of data it should contain.

int - holds values between -32,768 and 32,767


unsigned int - holds values between 0 and 65,535
char - holds a letter
float - holds a decimal
bool - holds either a true or a false (a 1 or a 0)
An Arduino Program
Variable Comments

Program
functions
Conditional
statement

Equation
Conditional Statements
We use logic operators to make decisions.

Equal (A == B) Not equal (A != B)


Greater than (A > B) Less than (A < B)
AND (A && B) OR (A || B)
Conditional Statements

"if" statement

What will this do?


Conditional Statements

"while" loop

And this?
Conditional Statements

"for" loop

What about this?


Functions
A way for us to tidy up and reuse our code.

Functions are called from within our main


loop (or from within other functions).
Libraries
Another way for us to tidy up our code.

Provides us with functions and tools to operate hardware


without us having to know exactly how the hardware works.

This operation adds code to our program behind the


scenes, i.e. we don't see it but we can still call its functions.

We read the library documentation to find out what those


functions are.
The Arduino IDE

If you are using your own computer, and you haven’t


already, you should download and install the IDE now:

https://www.arduino.cc/en/software/
TASKS

Open Arduino IDE on your computer.

Go to evolocity.co.nz > Workshops > Introduction to Arduino.

Download the Arduino Workshop Guidebook.

Turn to the Getting Started section.

Start working through the exercises.


Attach the Arduino
Test your kit

1. Connect the Arduino to your


computer
2. Load the example sketch “Blink”
(File>Examples>01.Basics>Blink)
3. Click “Select Board” and search
for “Arduino Nano”
4. Click the right arrow (the
“Upload” button)
5. Watch the LED on the Arduino
1.1 Blinking an LED

1. Run example 1.1


2. Try to explain what you think
the code is doing to a partner
3. Do the “Try This” section
1.2 Reading a Button

1. Run example 1.2


2. Try to explain what you think
the code is doing to a partner
3. Do the “Try This” section
2.1 Sending a Serial Message
2.1 Sending a Serial Message
3.1 Reading the Dial
3.1 Reading the Dial
3.2 Using a
Potentiometer to
Control LEDs
3.3 Measuring Battery Voltage

Pretend that your dial is the battery voltage sensor.

Have a go at programming this yourself, using this


equation to calculate the battery voltage.

Use one of the previous examples to help you!


3.3 Measuring Battery Voltage
3.4 Measuring Battery
Temperature

Connect your thermistor to the JST


XH connector on your motherboard.

Have a go at programming this


yourself.

Use the guidebook for the required


maths.
3.4 Measuring Battery
Temperature
4.1 Communicating
with an LCD
4.2 Measuring Data from
the BME280 Sensor
4.2 Measuring Data from
the BME280 Sensor

1. Click the books icon on the left of


your screen
2. Search for and install the
“Adafruit BME280” library

Make sure to use version 2.3.0 to avoid


compatibility issues during the workshop.
4.2 Measuring Data from
the BME280 Sensor

Find the documentation.

Use the link in the guidebook, or google “Adafruit


BME280 library Arduino”.

Note that we are using SPI, not I2C.

See if you can get a temperature reading from the


BME280 sensor.
4.2 Measuring Data from
the BME280 Sensor
5 Putting It All Together

You can now:


Measure battery voltage
Measure battery temperature
Measure ambient (BME280) temperature
Display it all on-screen

Try to combine this into one program.


THANK YOU FOR
COMING

You might also like