SlideShare a Scribd company logo
How to use Arduino
www.arduino.cc
By: Andrew Hoffmaster
Computers
• Computers talk in ones and zeros binary
• We need language to convert English to Binary
• The converter commonly used is C
What is a microcontroller
• Portable DAQ with on board processing
power
• Used everywhere: power strips, calculators
• Versatile with wide range of applications
Advantages and Disadvantages of
Microcontrollers
• Advantages
– Small
– Portable
– No Computer required
– Programmable logic
– Vast range of
applications
– Cheap
• Disadvantages
– Limited by ADC
– Limited processing
power
– No data storage
Arduino
• Italian made by ATMEGA
• Development boards allow for easy use and
adaptability
• Open source programming language
• “Plug in and use” usability
Development boards
http://arduino.cc/en/Main/Hardware
Digital I/O
Analog inputsPower outputs
USB input
9V external
power source
Initial steps
• Go to www.arduino.cc
• Download the latest version for you computer
http://arduino.cc/en/Main/Software
• You may need to download drivers for the
board you are using ( UNO or MEGA) but they
come with the download they are just difficult
to locate
Basics of Coding Arduino
• Arduino’s programming language is a version
of C, most C commands work in the sketch
editor
• Four basic components of Ardunio speak
– Initialization
– Setup
– Loop
– User defined functions
Initialization
• Include any extra libraries you are using
• All variables need to be initialized
• A=4; will not work int a= 4; will
• Define variables you will assign later
– Int a,b,c;
• Remember data structures
– Int, double, float, char, string ….
Here you can see the library
Math.h is included in the code this
will allow the use to use math
functions like cos sin tan …
ax, ay, az, gx, gy, gz are defined
to specific values
These values will be assigned later
but need to be initialized
Setup
• Initialization for the arduino board
• Usually begin Serial communication
• Usually assign digital pins to input or output
Void means setup will not output anything
pinMode defines the state of digital
pins to OUPUT or INPUT.
Serial.begin(9600) opens serial
communication at 9600 baud
Loop
• Loop is the main portion of the arduino code
• Loop is what the microcontroller will do
forever
• This is very much like a never ending for loop
Arduino
User defined functions
• These functions can be called in the loop and
are usually responses to conditions that are
met in the loop.
• These functions must be defined with data
structure and output type
User defined functions
• Here is a basic map function for floats
• The user inputs a float x and the function
maps the number from an old data range to a
new data range.
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
• float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
• {
• return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
• }
Defines output type as float
and names function
mapFloat
Inputs and their data types in this case they are all
floats
Return is what the function output which is defined above as a float
The curly brackets { and } define what is inside the function these separate blocks
of code and are very important
You can indent the inside of the code it is up to you and what fits your style
Analog v Digital
• Analog is a continuous signal (Voltage) in
which the variable of the signal is a
representation of some other time varying
quantity. Hence analogous
• Digital is a physical signal that represents a
sequence of discrete values. On and off like
binary 1 and 0
ADC and DAC
• Analog Digital Converter- Computer cannot
read Analog values only digital ( 5V or Gnd)
• Measured in bits 2^n example 10 bit = 2^10
= 1024
• Digital Analog Converter convert digitals signal
to analog signal, Voltage
Analog to Digital
• Computers read Digital signals
• Some sensors output analog signals (Voltage)
• We read this voltage as a Bit
– On a 5V analog pin 2.5 V is half of the number of
available bits
• Precision depends on the number of Bits in
our ADC
– With a 10 bit ADC bit= (Voltage/Vref )* num bits
ADC
Example
• A 2.5 V signal is applied to a 5Vref analog pin
with a 10 bit ADC what bit is displayed?
– Answer: (2.5 / 5) * 1024 = 512
Analog Data
• The Arduino has analog ports labeled Analog
in
• These are 10 bit data inputs that range from 0
to 5V although this can be changed
• Information is sent to the computer through
USB line using the Serial library.
• Information can also be sent via the serial
lines in the arduino
Simple Serial Communication
• Two wire communication
– Tx to write data to an object
– Rx to receive data
– Labeled as digital ports 0 (Rx) and 1(Tx) on arduino
• For USB communication select the correct
device (tools – board) and com port
• Open serial monitor to view incoming serial
data (top right icon)
Serial Library
• Serial.begin(baudrate)
– Opens Serial Port at baudrate
• Serial.avilable()
– Returns the number of bytes available to read
• Serial.read()
– Returns the first byte of incoming serial data available (or -1 if no data
is available)
• Serial.print(data,format)
– Prints data to the serial port as readable ASCII text
• Serial.println(data,format)
• Prints data to the serial port as readable ASCII text then ends the line
• http://arduino.cc/en/Reference/Serial
Analog Library
• analogReference(type)
– Default is 5 V signal External is voltage applied to
VREF
• analogRead(port)
– Reads data coming into analog port, 1024 values
or 10 bit data
• http://arduino.cc/en/Reference/AnalogRefere
nce
Digital Library
• pinMode(pin,mode)
– Set as INPUT or OUTPUT
• digitalWrite(pin,state)
– Write to HIGH 5v or LOW 0v or ground
• digitalRead(pin)
– Returns high or low (1 or 0)
Control Structrues
If(variable comparison operator condition)
{
do something
}
for(initialization; condition; increment)
{
do something
}
Computer checks to see if the
condition is met for the variable
and responds accordingly
Computer does something for a
certain number of time for
example read 500 lines of data
very quickly
Comparison Operators
• == equal to
• != not equal to
• < less than
• > greater than
• <= less than or equal to
• >= greater than or equal to
Boolean Operators
• && and
• || or
• ! not
Compound Operators
• ++ increment
• -- decrement
• += compound addition
• -= compound subtraction
• *= compound multiplication
• /= compound division
What are compound operators?
• X+=4 is the same as X=X+4
• X*=2 is the same as X=X*2
• X=1 X++ means X=1 and during the next
loop X=X+1 or X+=1
Data Structures
• Int
• Double
• Float
• Char
• String
• Hex
How to start coding
Hardware setup
• Use a USB A to B cable to plug you computer
into the arduino
• Plug the desired signals into the ports you
choose (Digital to digital ports)
• Make sure to plug in LED’s the correct way
How to start coding
Software setup
Open the Arduino main
window shown on the left
Download is available at
www.arduino.cc
Arduino environment
http://www.ladyada.net/learn/arduino/lesson1.html
Uploading code
Compile Upload Serial
Monitor
Under tools make sure Board is the board you and using and Serial
port is checked and is the correct port
First Code
Blink explained
• There are no variables assigned in this code
so the first part is the setup
• We are not using any Serial communication so
we only need to initialize the pinMode
• Writing the pin state to High will turn the LED
on the board on, writing it to Low will turn the
LED off
• The delay is in ms which causes the blink
Potentiometer setup
• Attach the outer wires of the potentiometer
to the +5 and ground outputs on the arduino
• Insert the center wire on the potentiometer to
the Analog input 0 (A0)
Arduino
Advanced Projects
• Each project using arduino will be a
combination of complex circuits and
programming
• The two basic places of failure are faulty
wiring or faulty coding
Wiring tips
• Always look at data sheet or schematic
• Ground all circuits
• Do not confuse analog and digital i/o
• Digital outputs can only output 0 or 5 V and
very low current <500ma
• Use digital out with relays for high current
applications
Coding tips
• Always follow basic structure initialize, setup,
loop, user functions
• If you do not know how to do something use
the internet
• Arduino forum is very helpful
• Keep trying
Arduino

More Related Content

What's hot (20)

PPTX
Msp 430 architecture module 1
SARALA T
 
PPT
ARM Micro-controller
Ravikumar Tiwari
 
PPTX
RS 232
Sandeep Kamath
 
PPTX
Interfacing technique with 8085- ADC[0808]
Guhan k
 
PPTX
8051 programming skills using EMBEDDED C
Aman Sharma
 
PPTX
Pic 18 microcontroller
Ashish Ranjan
 
PPT
PIC Microcontrollers.ppt
Dr.YNM
 
PPT
IoT with Arduino
Arvind Singh
 
PPT
Microprocessor ppt
swaminath kanhere
 
PPTX
MICROCONTROLLER 8051- Architecture & Pin Configuration
AKHIL MADANKAR
 
PDF
8259 Programmable Interrupt Controller
abhikalmegh
 
PPT
Microprocessor & microcontroller
Nitesh Kumar
 
PPTX
LCD Interacing with 8051
Sudhanshu Janwadkar
 
PPTX
I/O port programming in 8051
ssuser3a47cb
 
PPTX
Microprocessor 8086
Gopikrishna Madanan
 
PPT
8085-microprocessor
ATTO RATHORE
 
PPTX
Microprocessor Presentation
alaminmasum1
 
PPT
Embedded System Basics
Dr M Muruganandam Masilamani
 
PPT
Pin diagram of 8085
ShivamSood22
 
PPTX
PPT ON Arduino
Ravi Phadtare
 
Msp 430 architecture module 1
SARALA T
 
ARM Micro-controller
Ravikumar Tiwari
 
Interfacing technique with 8085- ADC[0808]
Guhan k
 
8051 programming skills using EMBEDDED C
Aman Sharma
 
Pic 18 microcontroller
Ashish Ranjan
 
PIC Microcontrollers.ppt
Dr.YNM
 
IoT with Arduino
Arvind Singh
 
Microprocessor ppt
swaminath kanhere
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
AKHIL MADANKAR
 
8259 Programmable Interrupt Controller
abhikalmegh
 
Microprocessor & microcontroller
Nitesh Kumar
 
LCD Interacing with 8051
Sudhanshu Janwadkar
 
I/O port programming in 8051
ssuser3a47cb
 
Microprocessor 8086
Gopikrishna Madanan
 
8085-microprocessor
ATTO RATHORE
 
Microprocessor Presentation
alaminmasum1
 
Embedded System Basics
Dr M Muruganandam Masilamani
 
Pin diagram of 8085
ShivamSood22
 
PPT ON Arduino
Ravi Phadtare
 

Viewers also liked (18)

PPTX
A Fast Introduction to Arduino and Addressable LED Strips
atuline
 
PDF
Introduction to Arduino Programming
James Lewis
 
PDF
What is arduino
vivek kumar
 
PPT
Intro to the arduino
ayreonmx
 
PDF
Blinky 101 with Arduino v1.0b3 (FastLED)
kriegsman
 
PDF
LinnStrument : the ultimate open-source hacker instrument
Geert Bevin
 
PPTX
Programming Addressable LED Strips
atuline
 
PPTX
Using arduino and raspberry pi for internet of things
Sudar Muthu
 
PPTX
Presentation for EEE engineers on Microcontroller by Dilip Kumar Roy
Dilip Kumar Ckt
 
PPTX
Spec sheet by pratik solanki
pratik solanki
 
PPTX
Feed mechanism by pratik solanki
pratik solanki
 
PPTX
Introduction to automation ppt
Himani Harbola
 
PPT
Arduino
vipin7vj
 
PPTX
automation slides,plc,scada,HMI
BOSCH
 
PDF
PLC and SCADA training.
Ishank Ranjan
 
PDF
Arduino Lecture 1 - Introducing the Arduino
Eoin Brazil
 
PPTX
Basics of Automation, PLC and SCADA
Indira Kundu
 
A Fast Introduction to Arduino and Addressable LED Strips
atuline
 
Introduction to Arduino Programming
James Lewis
 
What is arduino
vivek kumar
 
Intro to the arduino
ayreonmx
 
Blinky 101 with Arduino v1.0b3 (FastLED)
kriegsman
 
LinnStrument : the ultimate open-source hacker instrument
Geert Bevin
 
Programming Addressable LED Strips
atuline
 
Using arduino and raspberry pi for internet of things
Sudar Muthu
 
Presentation for EEE engineers on Microcontroller by Dilip Kumar Roy
Dilip Kumar Ckt
 
Spec sheet by pratik solanki
pratik solanki
 
Feed mechanism by pratik solanki
pratik solanki
 
Introduction to automation ppt
Himani Harbola
 
Arduino
vipin7vj
 
automation slides,plc,scada,HMI
BOSCH
 
PLC and SCADA training.
Ishank Ranjan
 
Arduino Lecture 1 - Introducing the Arduino
Eoin Brazil
 
Basics of Automation, PLC and SCADA
Indira Kundu
 
Ad

Similar to Arduino (20)

PPTX
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
 
PDF
Arduino microcontroller ins and outs with pin diagram
ArifatunNesa
 
PPTX
Arduino course
Ahmed Shelbaya
 
PDF
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
PPTX
Introduction to the Arduino
Wingston
 
PPTX
arduino and its introduction deep dive ppt.pptx
SruSru1
 
PPTX
Introduction to Arduino Microcontroller
Mujahid Hussain
 
PPTX
Arduino Programming Familiarization
Amit Kumer Podder
 
PPTX
IOT beginnners
udhayakumarc1
 
PPTX
IOT beginnners
udhayakumarc1
 
PDF
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
PPTX
Arduino Programming - Brief Introduction
NEEVEE Technologies
 
PPTX
Introduction to arduino!
Makers of India
 
PPT
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
PPTX
arduinoedit.pptx
rajalakshmi769433
 
PDF
AUTOMATIZACION LabVIEW LINX Arduino using SPI and I2C.pdf
AbHidalgo
 
PPTX
Arduino.pptx
AadilKk
 
PDF
Making things sense - Day 1 (May 2011)
markumoto
 
PPT
ARDUINO AND ITS PIN CONFIGURATION
soma saikiran
 
PPTX
Introduction To Arduino-converted for s.pptx
rtnmsn
 
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
 
Arduino microcontroller ins and outs with pin diagram
ArifatunNesa
 
Arduino course
Ahmed Shelbaya
 
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
Introduction to the Arduino
Wingston
 
arduino and its introduction deep dive ppt.pptx
SruSru1
 
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Arduino Programming Familiarization
Amit Kumer Podder
 
IOT beginnners
udhayakumarc1
 
IOT beginnners
udhayakumarc1
 
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Arduino Programming - Brief Introduction
NEEVEE Technologies
 
Introduction to arduino!
Makers of India
 
01 Intro to the Arduino and it's basics.ppt
pindi2197
 
arduinoedit.pptx
rajalakshmi769433
 
AUTOMATIZACION LabVIEW LINX Arduino using SPI and I2C.pdf
AbHidalgo
 
Arduino.pptx
AadilKk
 
Making things sense - Day 1 (May 2011)
markumoto
 
ARDUINO AND ITS PIN CONFIGURATION
soma saikiran
 
Introduction To Arduino-converted for s.pptx
rtnmsn
 
Ad

Recently uploaded (20)

PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 

Arduino

  • 1. How to use Arduino www.arduino.cc By: Andrew Hoffmaster
  • 2. Computers • Computers talk in ones and zeros binary • We need language to convert English to Binary • The converter commonly used is C
  • 3. What is a microcontroller • Portable DAQ with on board processing power • Used everywhere: power strips, calculators • Versatile with wide range of applications
  • 4. Advantages and Disadvantages of Microcontrollers • Advantages – Small – Portable – No Computer required – Programmable logic – Vast range of applications – Cheap • Disadvantages – Limited by ADC – Limited processing power – No data storage
  • 5. Arduino • Italian made by ATMEGA • Development boards allow for easy use and adaptability • Open source programming language • “Plug in and use” usability
  • 7. Initial steps • Go to www.arduino.cc • Download the latest version for you computer http://arduino.cc/en/Main/Software • You may need to download drivers for the board you are using ( UNO or MEGA) but they come with the download they are just difficult to locate
  • 8. Basics of Coding Arduino • Arduino’s programming language is a version of C, most C commands work in the sketch editor • Four basic components of Ardunio speak – Initialization – Setup – Loop – User defined functions
  • 9. Initialization • Include any extra libraries you are using • All variables need to be initialized • A=4; will not work int a= 4; will • Define variables you will assign later – Int a,b,c; • Remember data structures – Int, double, float, char, string ….
  • 10. Here you can see the library Math.h is included in the code this will allow the use to use math functions like cos sin tan … ax, ay, az, gx, gy, gz are defined to specific values These values will be assigned later but need to be initialized
  • 11. Setup • Initialization for the arduino board • Usually begin Serial communication • Usually assign digital pins to input or output
  • 12. Void means setup will not output anything pinMode defines the state of digital pins to OUPUT or INPUT. Serial.begin(9600) opens serial communication at 9600 baud
  • 13. Loop • Loop is the main portion of the arduino code • Loop is what the microcontroller will do forever • This is very much like a never ending for loop
  • 15. User defined functions • These functions can be called in the loop and are usually responses to conditions that are met in the loop. • These functions must be defined with data structure and output type
  • 16. User defined functions • Here is a basic map function for floats • The user inputs a float x and the function maps the number from an old data range to a new data range. float mapFloat(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }
  • 17. • float mapFloat(float x, float in_min, float in_max, float out_min, float out_max) • { • return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; • } Defines output type as float and names function mapFloat Inputs and their data types in this case they are all floats Return is what the function output which is defined above as a float The curly brackets { and } define what is inside the function these separate blocks of code and are very important You can indent the inside of the code it is up to you and what fits your style
  • 18. Analog v Digital • Analog is a continuous signal (Voltage) in which the variable of the signal is a representation of some other time varying quantity. Hence analogous • Digital is a physical signal that represents a sequence of discrete values. On and off like binary 1 and 0
  • 19. ADC and DAC • Analog Digital Converter- Computer cannot read Analog values only digital ( 5V or Gnd) • Measured in bits 2^n example 10 bit = 2^10 = 1024 • Digital Analog Converter convert digitals signal to analog signal, Voltage
  • 20. Analog to Digital • Computers read Digital signals • Some sensors output analog signals (Voltage) • We read this voltage as a Bit – On a 5V analog pin 2.5 V is half of the number of available bits • Precision depends on the number of Bits in our ADC – With a 10 bit ADC bit= (Voltage/Vref )* num bits ADC
  • 21. Example • A 2.5 V signal is applied to a 5Vref analog pin with a 10 bit ADC what bit is displayed? – Answer: (2.5 / 5) * 1024 = 512
  • 22. Analog Data • The Arduino has analog ports labeled Analog in • These are 10 bit data inputs that range from 0 to 5V although this can be changed • Information is sent to the computer through USB line using the Serial library. • Information can also be sent via the serial lines in the arduino
  • 23. Simple Serial Communication • Two wire communication – Tx to write data to an object – Rx to receive data – Labeled as digital ports 0 (Rx) and 1(Tx) on arduino • For USB communication select the correct device (tools – board) and com port • Open serial monitor to view incoming serial data (top right icon)
  • 24. Serial Library • Serial.begin(baudrate) – Opens Serial Port at baudrate • Serial.avilable() – Returns the number of bytes available to read • Serial.read() – Returns the first byte of incoming serial data available (or -1 if no data is available) • Serial.print(data,format) – Prints data to the serial port as readable ASCII text • Serial.println(data,format) • Prints data to the serial port as readable ASCII text then ends the line • http://arduino.cc/en/Reference/Serial
  • 25. Analog Library • analogReference(type) – Default is 5 V signal External is voltage applied to VREF • analogRead(port) – Reads data coming into analog port, 1024 values or 10 bit data • http://arduino.cc/en/Reference/AnalogRefere nce
  • 26. Digital Library • pinMode(pin,mode) – Set as INPUT or OUTPUT • digitalWrite(pin,state) – Write to HIGH 5v or LOW 0v or ground • digitalRead(pin) – Returns high or low (1 or 0)
  • 27. Control Structrues If(variable comparison operator condition) { do something } for(initialization; condition; increment) { do something } Computer checks to see if the condition is met for the variable and responds accordingly Computer does something for a certain number of time for example read 500 lines of data very quickly
  • 28. Comparison Operators • == equal to • != not equal to • < less than • > greater than • <= less than or equal to • >= greater than or equal to
  • 29. Boolean Operators • && and • || or • ! not
  • 30. Compound Operators • ++ increment • -- decrement • += compound addition • -= compound subtraction • *= compound multiplication • /= compound division
  • 31. What are compound operators? • X+=4 is the same as X=X+4 • X*=2 is the same as X=X*2 • X=1 X++ means X=1 and during the next loop X=X+1 or X+=1
  • 32. Data Structures • Int • Double • Float • Char • String • Hex
  • 33. How to start coding Hardware setup • Use a USB A to B cable to plug you computer into the arduino • Plug the desired signals into the ports you choose (Digital to digital ports) • Make sure to plug in LED’s the correct way
  • 34. How to start coding Software setup Open the Arduino main window shown on the left Download is available at www.arduino.cc
  • 36. Uploading code Compile Upload Serial Monitor Under tools make sure Board is the board you and using and Serial port is checked and is the correct port
  • 38. Blink explained • There are no variables assigned in this code so the first part is the setup • We are not using any Serial communication so we only need to initialize the pinMode • Writing the pin state to High will turn the LED on the board on, writing it to Low will turn the LED off • The delay is in ms which causes the blink
  • 39. Potentiometer setup • Attach the outer wires of the potentiometer to the +5 and ground outputs on the arduino • Insert the center wire on the potentiometer to the Analog input 0 (A0)
  • 41. Advanced Projects • Each project using arduino will be a combination of complex circuits and programming • The two basic places of failure are faulty wiring or faulty coding
  • 42. Wiring tips • Always look at data sheet or schematic • Ground all circuits • Do not confuse analog and digital i/o • Digital outputs can only output 0 or 5 V and very low current <500ma • Use digital out with relays for high current applications
  • 43. Coding tips • Always follow basic structure initialize, setup, loop, user functions • If you do not know how to do something use the internet • Arduino forum is very helpful • Keep trying