Arduino
Arduino
with Arduino
Linz Craig, Brian Huang
Agenda
• About us / Introductions
• Software Installation
• What can it do? Who cares?
• Blink Sketch Disco Lights
• Using Variables
• If() statement reading buttonPress
• Analog Sensors Fading
• Making Sound
About Us
Open Source
Free
Available on-line with resources at:
www.arduino.cc
What can it do?
•Great for prototyping ideas
•Flexible / Open-source
Who cares?
Hackers / Makers
Engineers
Artists
Musicians
Kids!
Teachers!!
You!!!
Setup Board Type
Tools → Board → Arduino Uno
Setup Serial COM Port
Tools → Serial Port →
Notes:
PC –
Highest COM #
Mac –
/dev/tty.usbserial-A####xxx
Analog and Digital
• All Arduino signals are either Analog or Digital
• All computers including Arduino, only
understand Digital
• It is important to understand the difference
between Analog and Digital signals since Analog
signals require an Analog to Digital conversion
Input vs. Output
Everything is referenced from the perspective of the
microcontroller.
void setup()
{
// runs once
}
void loop()
{
// repeats forever!!!
}
Let’s get to hacking…
Project #1 – Blink
“Hello World” of Physical Computing
pinMode(pin, INPUT/OUTPUT);
ex: pinMode(13, OUTPUT);
digitalWrite(pin, HIGH/LOW);
ex: digitalWrite(13, HIGH);
delay(time_ms);
ex: delay(2500);
LED Pin Configurations
LED1 = ~3;
LED2 = ~5;
10 3
LED3 = ~10;
LED4 = 13; 13 5
SIMON_2b_BLINK
Using Variables
To clean-up code, for read-ability, and flexibility – we can create
placeholders in code.
Example:
int ledPin = 3;
void setup(){
pinMode(ledPin, OUTPUT);
}
void loop(){
digitalWrite(ledPin, HIGH);
}
Digital Input
The Code:
Notes:
BUTTON1 = 2;
BUTTON2 = 6;
BUTTON3 = 9;
BUTTON4 = 12;
Button Pin Configurations
BUTTON1 = 2;
BUTTON2 = 6;
9 2
BUTTON3 = 9;
BUTTON4 = 12; 12 6