Arduino Presentation
Arduino Presentation
EDUCATIONAL
BOARD
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
TOPICS TO BE DISCUSSED
Arduno uno & pin
configuration
Input output pins
Analog & Digital Pins
How to install arduino IDE
Discuss basic C language
Led blink projecT
Error debugging in Arduino
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
ARDUINO
Introduction:-
Arduino is an open-source platform
used for building electronics projects.
Arduino consists of both a physical
programmable circuit board (often
referred to as a microcontroller) and a
piece of software, or IDE (Integrated
Development Environment) that runs on
your computer, used to write and upload
computer code to the physical board
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
PWR IN USB
(to Computer)
RESET
SCL\SDA
(I2C Bus)
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
USB
(to Computer) PWR IN
SCL\SDA
(I2C Bus)
Digital PIN
PWM(0,1,2,3,4,5,6,7 )
Analog
INPUTS
POWER
5V / 3.3V / GND RESET
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Go ahead and plug your board in!
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Concepts: INPUT vs. OUTPUT
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Concepts: Analog vs. Digital
Microcontrollers are digital devices – ON or OFF. Also
called – discrete.
5V 5V
0V 0V
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Open up Arduino
Hints:
For PC Users For Mac Users
1.Let the installer copy and 1. Move the Arduino
move the files to the executable to the dock
appropriate locations, or for ease of access.
2.Create a folder under C:\ 2. Resist the temptation to
Program Files (x86) called run these from your
Arduino. Move the entire desktop.
Arduino program folder here.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino
Integrated Development Environment (IDE)
void setup()
{
// runs once
}
void loop()
{
// repeats
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Settings: Tools Board
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial communication
analogRead()
if() statements / Boolean
digitalRead()
analogWrite() BIG 6 CONCEPTS
digitalWrite()
Comments, Comments, Comments
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
comments
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Three commands to know…
pinMode(pin, INPUT/OUTPUT);
ex: pinMode(13, OUTPUT);
digitalWrite(pin, HIGH/LOW);
ex: digitalWrite(13, HIGH);
delay(time_ms);
ex: delay(2500); // delay of 2.5 sec.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #1: Wiring Diagram
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
A few simple challenges
Let’s make LED#13 blink!
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Try adding other LEDs
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming Concepts: Variables
Variable Scope
Global
---
Function-level
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming Concepts: Variable Types
Variable Types:
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Fading in and Fading Out
(Analog or Digital?)
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Concepts: Analog vs. Digital
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #2 – Fading
Introducing a new command…
analogWrite(pin, val);
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Move one of your LED pins over to Pin 9
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Fade - Code Review
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Fade - Code Review
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
RGB LED Color Mixing
int redPin = 5;
int greenPin = 6;
int bluePin = 9;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
RGB LED Color Mixing
void loop()
{
analogWrite(redPin, 255);
analogWrite (greenPin, 255);
analogWrite (bluePin, 255);
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #4 – Digital Input
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Sensors (a.k.a. Switches)
Pull-up Resistor (circuit)
to Digital Pin 2
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Sensors (a.k.a. Switches)
Add an indicator LED to Pin 13
This is just like our
1st circuit!
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Input
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
http://opensourcehardwarejunkies.com/tutorial-03-digitalread-and-
serial-port-communication/
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming: Conditional Statements
if()
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming: Conditional Statements
if()
void loop()
{
int buttonState = digitalRead(5);
if(buttonState == LOW)
{ // do something DIG
INPUT
}
else
{ // do something else
}
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
analogRead()
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Using Serial Communication
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial Monitor & analogRead()
Opens up a
Serial Terminal
Window
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Analog Sensors
2 Pin Analog Sensors = var. resistor
MaxAnalogRead = _________
MinAnalogRead = _________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Analog Sensors
Examples:
Sensors Variables
Mic soundVolume
Photoresistor lightLevel
Potentiometer dialPosition
Temp Sensor temperature
Flex Sensor bend
Accelerometer tilt/acceleration
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Additional Serial Communication
Sending a Message
void loop ( )
{
Serial.print(“Hands on “) ;
Serial.print(“Learning ”) ;
Serial.println(“is Fun!!!”) ;
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial Communication:
Serial Debugging
void loop()
{
int xVar = 10;
Serial.print ( “Variable xVar is “ ) ;
Serial.println ( xVar ) ;
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial Communication:
Serial Troubleshooting
void loop ( )
{
Serial.print (“Digital pin 9: “);
Serial.println (digitalRead(9));
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.