SlideShare a Scribd company logo
1 of 84
Introduction to Arduino
With ArduBlock & LilyPad Dev
Brian Huang
Education Engineer
brian.huang@sparkfun.com
Pre-Class Survey
http://bit.ly/14Xk3Ek
Resources
This PPT 
ArduBlock Download & Installation 
http://www.ardublock.com/
Installation Process
ArduBlock is a run-time Java script that must be
saved to a specific location on your computer.
The file ardublock-xxxx.jar must be inside the
following file structure within your Arduino
sketchbook:
ArduinotoolsArduBlockTooltool
Note: Folder names are case sensitive
General Rules
Raise your hand if you have a question.
Be respectful.
When I raise my hand…
Share your findings with the people near
you.
Poke around, experiment, and have fun…
Imagine, create, and play!!!
Objectives
Provide a thorough introduction to the Arduino
programming environment.
Develop a use of simple functions to interact
with the LEDs, light sensor, push button, and
buzzer on the Protosnap Pro Mini.
Arduino LilyPad Protosnap Dev
What is it?
What can it do?
Who cares?
What is it?
Heart of it – ATMega328 (a $4 microcontroller)
Open Source
High tolerance for ESD and “bad” electronics
practices…
Provides easy way to interact with a computer
physically – a.k.a. physical computing
What can it do?
- Great for prototyping
ideas
- Great to teach Intro to
Programming Arduino
(no assembly required!)
- Lots and lots of options!
- Large pads can be sew-
able
Who cares?
Hackers / Makers
Engineers
Artists
Musicians
Kids!
Teachers!!
You!!!
Physical Computing
What is all this stuff???
Components
Buzzer /
Speaker
Light
Sensor
Temp.
Sensor
the Brain
ATmega328
(16 MHz clock)
What is all this stuff???
Silk Screen & Pins
Actual Pins
on Atmega328
Startup Arduino IDE
Double-click on either
the Arduino Icon or
wherever you
installed (saved) the
Arduino program.
Plug it in
Lesson #0a – Setting up Arduino
1.Setup Board
(LilyPad Arduino w/ ATmega328)
2.Setup COM Port
PC – Highest COM #
Mac – /dev/tty.usbserial-A####xXx
Tools  Board
Setup Board
Tools  Serial Port
Setup COM Port
PC –
Highest COM #
Mac –
/dev/tty.usbserial-
A####xxx
Other Board Types
Tools  ArduBlock
Load ArduBlock
Programming
Area
Zoomed out
View
Programming
Blocks Palate
What is ArduBlock?
• Graphical Introduction to Programming
• Scratch-like interface
• Clear transition to text-based coding
• Generates real Arduino code in the
background.
Block Organization
Manipulating or modifying the program
flow or behavior.
Serial and I2C communication:
transferring data between devices & PC
Special utilities: Tone, servo, and
ultrasonic sensors
Creating, assigning, or using constants,
variables, or arrays.
Simple and complex math operations.
Boolean logic operations and
comparisons.
Reading or setting values (voltages) to
pins on the microcontroller.
Block Organization
Control
Manipulating or modifying the program
flow or behavior.
Pin # – any number
from 0 to 19
Values –
Pin # – 3, 5, 6, 9, 10, or
11 .
Values –
Allows the control of the pins on the Atmega328
chip – turning them on or off (like the light
switch)
Block Organization
Pins
or to
Notice the different
shapes?
Digital Values Analog (Number) Values
Lesson #0b – Test Upload
Notes:
• Click and drag blocks from the left pane to the Programming Area.
• Blocks should snap/click together.
• Right-click to copy-paste (clone) a block
• Drag blocks back to the left pane to discard.
Click Upload to Arduino and watch…
Create the following program -- What do you expect this to do?
Click back to the Arduino window to
check for status messages
What do you see?
LED on pin #13
What about turning the LED off?
Click to change the HIGH to a LOW
Let’s get to hacking…
Lesson #1 – What if I want to Blink?
“Hello World” of Physical Computing
Psuedo-code – how should this work?
Turn
LED ON
Wait
Turn
LED
OFF
Wait
Rinse &
Repeat
Let’s get to hacking…
Lesson #1 – What if I want to Blink?
“Hello World” of Physical Computing
Runs once at the beginning of code.
Repeats – continuously over and
over and over…
Example
What other LEDs can we play
with?
16 18 17
Pins with an A are actually Analog INPUT
pins – but they’re really identified as…
Digital Pins are numbered 0 to 13.
Analog Input Pins are A0 to A5. but…
Analog Pin Digital I/O ID
A0  14
A1  15
A2  16
A3  17
A4  18
A5  19
AnalogPinMapping
Alright? Let’s blink!
Challenge 1a – Blink to mimic a heartbeat
Challenge 1b – Blink multiple LEDs
First -- plan out a pattern on paper – then
start coding
Challenge 1c – Multiple LEDS – Knight
Rider (Cylon)-esque
Save your Project
• Save early, Save
often!
• Enumerate your
iterations – (e.g.
blink_10.adp,
blink_11.adp,
blink_12.adp…)
Speeding up and Slowing
Down…
What if we wanted to create a pattern that starts off
with a slow blink and gets faster and faster?
What part do we need to be able to change?
constant
Programming Concepts:
Using Variables
Variable Types:
8 bits 16 bits 32 bits
byte
char
int
unsigned int
long
unsigned long
float
Using Variables in ArduBlock
Numbers/Constants
Variable is just a
placeholder for a
value.
This placeholder can
be manipulated
within the code.
Start by setting a variable called
delayTime in the setup
Now… replace the 1000 in each
delay with the variable name
Decrement delayTime each loop
– using Math Operators
Example: Did you come up with
something like this?
What happens when you reach zero?
Let’s find out!
Debugging – how can we see what’s going on?
Serial Monitor
Serial print
command
Any
message
“glue”
Data
Add this block… so that we can
watch the variable value
Upload & Click back to Arduino
Open the Serial Monitor
How do we fix / prevent this from
happening?
If this is TRUE…
Do this.
Otherwise,
do this.
Conditional Logic:  If(), If() – else…
Logical Operators
Comparisons / Conditionals
Greater than
Less than
Equal to
Greater than or equal to
Less than or equal to
Not equal to
If delayTime <= 0… reset
Advanced…
Combinations of inequalities
Combine multiple conditions together using
or and and
Example:
Other than just turning an LED on
and off…
What else might we want to do?
Concept: Analog vs. Digital
Micro-controllers are digital devices – ON or OFF.
An Analog signal is anything that can be a full
range of values. xWhat are some examples?
Think of like a ramp or a hill.
Concept: Analog vs. Digital
To create an analog signal, the
microcontroller uses a technique called
PWM.
Pulse Width Modulation (PWM)
Pins 3, 5, 6, 9, 10, 11 are capable of producing an
Analog Output
Color Mixing with 3 LEDs
RGB LED
Challenge 2a:
1) Experiment with different values – what do you observe
happens? Be prepared to share with the class – what
did you try, and what did you see?
2) Do you observe anything strange about the behavior?
3) How do you create Orange? Purple? Magenta?
LED PINS
RED = 9
GREEN = 11
BLUE = 10
Change either of these
values… See what happens!
Color Mixing with 3 LEDs
Tri-color LED
The RGB LED is a Common-Anode (means the
positive side of the LED is all tied to Vcc).
The signal line is connected to the bottom of each
LED.
Don’t worry - it’s just a different method of
completing a circuit!
Pin
9
Pin
11
Pin
10
5 V
Value = 0 (LOW)  LED is ON
Value = 255 (HIGH)  LED is OFF
Color Mixing with 3 LEDs
Challenge 2b:
Experiment with different values of Red, Green, and Blue
to create a couple different colors.
Write down the values you used. Check these values
with www.colorpicker.com
Challenge 2c:
Create a unique lighting display that blinks, fades, or
switches colors. Be prepared to have a name for your art
piece and show this to the rest of the class.
Save your Project #2
New Challenge
Handling Inputs
A Simple Example
Try this bit of code.
What do you think will happen? Test it
and write down your observations.
DIG
INPUT 2
digital Inputs
Buttons / Slide Switches
INPUT A5
INPUT A5
(a.k.a. 19)
What about
this??
Analog Pin Digital I/O ID
A0  14
A1  15
A2  16
A3  17
A4  18
A5  19
AnalogPinMapping
digital Inputs
Buttons / Slide Switches
Challenge 3a:
Re-arrange the blocks or add new ones to:
• Blink LED quickly when the button is pressed.
• Otherwise blink slow
Same as
Pin A5
digital Inputs
Buttons / Slide Switches
Challenge 3b:
Now, using the button / switch – to start a disco/light changing
pattern
Challenge 3c:
Now, using the button / switch – to turn on and off the VIBE
motor.
Reading the
Light Sensor?
What is the biggest and smallest value the analog pin will
“measure”? [Hint: open your serial monitor to find out!]
Challenge
Use the light sensor input to affect the blink
rate of the LEDs.
Use the light sensor input to affect the speed
of a “knight-rider” or cylon display.
Use the light sensor to ___________.
Save your Project #3
Sensors
Making Music
Setting up the Speaker
Three simple blocks to play with…
Making Music
Let’s Play a song…
Twinkle-Twinkle:
CC GG AA G FF EE DD C GG
Happy Birthday:
G G A G C B G G A G D C G G G E C C B A
Hot Cross Buns:
B A G <> B A G <> G G G G <> A A A A B A G
Mary Had A Little Lamb:
B A G A BB B <> AA A <> BB B <>
B A G A BBBB AAA BAG.
Musical Notes / Frequencies
Note Frequency (Hz)
C4 261
C#
4/Db
4 277
D4 293
D#
4/Eb
4 311
E4 329
F4 349
F#
4/Gb
4 369
G4 392
G#
4/Ab
4 415
A4 440
A#
4/Bb
4 466
B4 493
Note Frequency (Hz)
C5 523
C#
5/Db
5 554
D5 587
D#
5/Eb
5 622
E5 659
F5 698
F#
5/Gb
5 739
G5 783
G#
5/Ab
5 830
A5 880
A#
5/Bb
5 932
B5 987
Save your Project #4
Tone
Getting started with Arduino
Additional Resources
http://www.sparkfun.com
http://learn.sparkfun.com
http://www.arduino.cc
http://www.bildr.org
SparkFun Tutorials and Projects
- GardenBot:
www.sparkfun.com/news/598
- High Altitude Balloon:
www.sparkfun.com/tutorials/180
- GPS Clock:
www.sparkfun.com/tutorials/47
- Earthquake Data Logger:
www.sparkfun.com/tutorials/235
Thousands of Amazing ideas…
The Cat Defender…
http://www.plasma2002.com/blenderdefende
r/
List of projects at Sparkfun:
https://learn.sparkfun.com/tutorials
Questions?
Before leaving, please fill out a quick survey
so that I can get your e-mail and a little
info about your familiarity with Arduino /
Sparkfun.
Thanks!
http://www.sparkfun.com/WorkshopFeedback
Feedback?
www.sparkfun.com
6175 Longbow Drive, Suite 200
Boulder, Colorado 80301

More Related Content

What's hot

Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshopatuline
 
Arduino spooky projects_class3
Arduino spooky projects_class3Arduino spooky projects_class3
Arduino spooky projects_class3Anil Yadav
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduinoavikdhupar
 
Arduino slides
Arduino slidesArduino slides
Arduino slidessdcharle
 
Arduino Day 1 Presentation
Arduino Day 1 PresentationArduino Day 1 Presentation
Arduino Day 1 PresentationYogendra Tamang
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full TutorialAkshay Sharma
 
Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hqAndreis Santos
 
Getting Started With Arduino_Tutorial
Getting Started With Arduino_TutorialGetting Started With Arduino_Tutorial
Getting Started With Arduino_TutorialNYCCTfab
 
Arduino Introduction Guide 1
Arduino Introduction Guide 1Arduino Introduction Guide 1
Arduino Introduction Guide 1elketeaches
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoEoin Brazil
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino ProgrammingJames Lewis
 
Arduino Model's
Arduino Model'sArduino Model's
Arduino Model'sAli Izmir
 
IOTC08 The Arduino Platform
IOTC08 The Arduino PlatformIOTC08 The Arduino Platform
IOTC08 The Arduino PlatformEoin Brazil
 
Intro to Hardware Programming with the Arduino Uno
Intro to Hardware Programming with the Arduino UnoIntro to Hardware Programming with the Arduino Uno
Intro to Hardware Programming with the Arduino UnoVui Nguyen
 

What's hot (20)

Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Arduino spooky projects_class3
Arduino spooky projects_class3Arduino spooky projects_class3
Arduino spooky projects_class3
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 
Arduino Day 1 Presentation
Arduino Day 1 PresentationArduino Day 1 Presentation
Arduino Day 1 Presentation
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full Tutorial
 
Ardui no
Ardui no Ardui no
Ardui no
 
Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hq
 
Getting Started With Arduino_Tutorial
Getting Started With Arduino_TutorialGetting Started With Arduino_Tutorial
Getting Started With Arduino_Tutorial
 
Arduino
ArduinoArduino
Arduino
 
Arduino Introduction Guide 1
Arduino Introduction Guide 1Arduino Introduction Guide 1
Arduino Introduction Guide 1
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the Arduino
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino Programming
 
Arduino Model's
Arduino Model'sArduino Model's
Arduino Model's
 
IOTC08 The Arduino Platform
IOTC08 The Arduino PlatformIOTC08 The Arduino Platform
IOTC08 The Arduino Platform
 
Arduino course
Arduino courseArduino course
Arduino course
 
Presentation S4A
Presentation S4A Presentation S4A
Presentation S4A
 
Intro to Hardware Programming with the Arduino Uno
Intro to Hardware Programming with the Arduino UnoIntro to Hardware Programming with the Arduino Uno
Intro to Hardware Programming with the Arduino Uno
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 

Viewers also liked

Make First, Teach Later: A Classroom Manifesto
Make First, Teach Later: A Classroom ManifestoMake First, Teach Later: A Classroom Manifesto
Make First, Teach Later: A Classroom ManifestoSparkFun Electronics
 
ATTiny Light Sculpture Project - Part II (MultiLEDs)
ATTiny Light Sculpture Project - Part II (MultiLEDs)ATTiny Light Sculpture Project - Part II (MultiLEDs)
ATTiny Light Sculpture Project - Part II (MultiLEDs)Brian Huang
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunJingfeng Liu
 
Presentación unidad 5: Programación de Sensores y Actuadores con ArduBlock
Presentación unidad 5: Programación de Sensores y Actuadores con ArduBlockPresentación unidad 5: Programación de Sensores y Actuadores con ArduBlock
Presentación unidad 5: Programación de Sensores y Actuadores con ArduBlockFRANCISCO GIMENEZ MOLLA
 
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM System
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM SystemLabmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM System
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM SystemSyuan Wang
 
Voice encryption for gsm using arduino
Voice encryption for gsm using arduinoVoice encryption for gsm using arduino
Voice encryption for gsm using arduinoiruldaworld
 
PrivateGSM - Voice Encryption Technical Overview
PrivateGSM - Voice Encryption Technical OverviewPrivateGSM - Voice Encryption Technical Overview
PrivateGSM - Voice Encryption Technical OverviewPrivateWave Italia SpA
 
Introduction to arduino
Introduction to arduinoIntroduction to arduino
Introduction to arduinoAhmed Sakr
 

Viewers also liked (10)

Presentación ArduBlock
Presentación ArduBlockPresentación ArduBlock
Presentación ArduBlock
 
Make First, Teach Later: A Classroom Manifesto
Make First, Teach Later: A Classroom ManifestoMake First, Teach Later: A Classroom Manifesto
Make First, Teach Later: A Classroom Manifesto
 
ATTiny Light Sculpture Project - Part II (MultiLEDs)
ATTiny Light Sculpture Project - Part II (MultiLEDs)ATTiny Light Sculpture Project - Part II (MultiLEDs)
ATTiny Light Sculpture Project - Part II (MultiLEDs)
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
Programación avanzada con ArduBlock
Programación avanzada con ArduBlockProgramación avanzada con ArduBlock
Programación avanzada con ArduBlock
 
Presentación unidad 5: Programación de Sensores y Actuadores con ArduBlock
Presentación unidad 5: Programación de Sensores y Actuadores con ArduBlockPresentación unidad 5: Programación de Sensores y Actuadores con ArduBlock
Presentación unidad 5: Programación de Sensores y Actuadores con ArduBlock
 
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM System
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM SystemLabmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM System
Labmeeting - 20150211 - Novel End-to-End Voice Encryption Method in GSM System
 
Voice encryption for gsm using arduino
Voice encryption for gsm using arduinoVoice encryption for gsm using arduino
Voice encryption for gsm using arduino
 
PrivateGSM - Voice Encryption Technical Overview
PrivateGSM - Voice Encryption Technical OverviewPrivateGSM - Voice Encryption Technical Overview
PrivateGSM - Voice Encryption Technical Overview
 
Introduction to arduino
Introduction to arduinoIntroduction to arduino
Introduction to arduino
 

Similar to Introduction to Arduino with ArduBlock & SparkFun LilyPad

arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfAbdErrezakChahoub
 
ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)Brian Huang
 
Arduino - Learning.pdf
Arduino - Learning.pdfArduino - Learning.pdf
Arduino - Learning.pdfKhalilSedki1
 
Hello Arduino.
Hello Arduino.Hello Arduino.
Hello Arduino.mkontopo
 
ScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClipScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClipDavid Dryden
 
Arduino spooky projects_class1
Arduino spooky projects_class1Arduino spooky projects_class1
Arduino spooky projects_class1Felipe Belarmino
 
Arduino Intro Guide 2
Arduino Intro Guide 2Arduino Intro Guide 2
Arduino Intro Guide 2elketeaches
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixelssdcharle
 
Notes arduino workshop_15
Notes arduino workshop_15Notes arduino workshop_15
Notes arduino workshop_15Faiz Lazim
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.pptZainIslam20
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshopmayur1432
 
Lily pad dev_handout
Lily pad dev_handoutLily pad dev_handout
Lily pad dev_handoutKhuê Phạm
 

Similar to Introduction to Arduino with ArduBlock & SparkFun LilyPad (20)

Arduino
Arduino Arduino
Arduino
 
Intro_to_Arduino_-_v30.pptx
Intro_to_Arduino_-_v30.pptxIntro_to_Arduino_-_v30.pptx
Intro_to_Arduino_-_v30.pptx
 
arduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdfarduinoworkshop-160204051621.pdf
arduinoworkshop-160204051621.pdf
 
What is arduino
What is arduinoWhat is arduino
What is arduino
 
ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)ATTiny Light Sculpture Project - Part I (Setup)
ATTiny Light Sculpture Project - Part I (Setup)
 
Arduino - Learning.pdf
Arduino - Learning.pdfArduino - Learning.pdf
Arduino - Learning.pdf
 
Presentation
PresentationPresentation
Presentation
 
Hello Arduino.
Hello Arduino.Hello Arduino.
Hello Arduino.
 
ScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClipScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClip
 
Arduino spooky projects_class1
Arduino spooky projects_class1Arduino spooky projects_class1
Arduino spooky projects_class1
 
Arduino Intro Guide 2
Arduino Intro Guide 2Arduino Intro Guide 2
Arduino Intro Guide 2
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
 
Notes arduino workshop_15
Notes arduino workshop_15Notes arduino workshop_15
Notes arduino workshop_15
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshop
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
 
Lily pad dev_handout
Lily pad dev_handoutLily pad dev_handout
Lily pad dev_handout
 

More from Brian Huang

Setting up the Arduino ATTiny
Setting up the Arduino ATTinySetting up the Arduino ATTiny
Setting up the Arduino ATTinyBrian Huang
 
Open-Source Hardware, Tinkering, and Physics Education
Open-Source Hardware, Tinkering, and Physics EducationOpen-Source Hardware, Tinkering, and Physics Education
Open-Source Hardware, Tinkering, and Physics EducationBrian Huang
 
Strategies for Educators Using Microcontrollers in the Classroom
Strategies for Educators Using Microcontrollers in the ClassroomStrategies for Educators Using Microcontrollers in the Classroom
Strategies for Educators Using Microcontrollers in the ClassroomBrian Huang
 
Scratch for Data Logging and Graphing
Scratch for Data Logging and GraphingScratch for Data Logging and Graphing
Scratch for Data Logging and GraphingBrian Huang
 
Maker Science with Arduino and SparkFun Electronics @NSTA14 Boston
Maker Science with Arduino and SparkFun Electronics @NSTA14 BostonMaker Science with Arduino and SparkFun Electronics @NSTA14 Boston
Maker Science with Arduino and SparkFun Electronics @NSTA14 BostonBrian Huang
 
Pop up paper engineering - cu boulder & centaurus
Pop up paper engineering - cu boulder & centaurusPop up paper engineering - cu boulder & centaurus
Pop up paper engineering - cu boulder & centaurusBrian Huang
 

More from Brian Huang (6)

Setting up the Arduino ATTiny
Setting up the Arduino ATTinySetting up the Arduino ATTiny
Setting up the Arduino ATTiny
 
Open-Source Hardware, Tinkering, and Physics Education
Open-Source Hardware, Tinkering, and Physics EducationOpen-Source Hardware, Tinkering, and Physics Education
Open-Source Hardware, Tinkering, and Physics Education
 
Strategies for Educators Using Microcontrollers in the Classroom
Strategies for Educators Using Microcontrollers in the ClassroomStrategies for Educators Using Microcontrollers in the Classroom
Strategies for Educators Using Microcontrollers in the Classroom
 
Scratch for Data Logging and Graphing
Scratch for Data Logging and GraphingScratch for Data Logging and Graphing
Scratch for Data Logging and Graphing
 
Maker Science with Arduino and SparkFun Electronics @NSTA14 Boston
Maker Science with Arduino and SparkFun Electronics @NSTA14 BostonMaker Science with Arduino and SparkFun Electronics @NSTA14 Boston
Maker Science with Arduino and SparkFun Electronics @NSTA14 Boston
 
Pop up paper engineering - cu boulder & centaurus
Pop up paper engineering - cu boulder & centaurusPop up paper engineering - cu boulder & centaurus
Pop up paper engineering - cu boulder & centaurus
 

Recently uploaded

Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 

Recently uploaded (20)

Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 

Introduction to Arduino with ArduBlock & SparkFun LilyPad

  • 1.
  • 2.
  • 3. Introduction to Arduino With ArduBlock & LilyPad Dev Brian Huang Education Engineer brian.huang@sparkfun.com
  • 5. Resources This PPT  ArduBlock Download & Installation  http://www.ardublock.com/
  • 6.
  • 7.
  • 8. Installation Process ArduBlock is a run-time Java script that must be saved to a specific location on your computer. The file ardublock-xxxx.jar must be inside the following file structure within your Arduino sketchbook: ArduinotoolsArduBlockTooltool Note: Folder names are case sensitive
  • 9. General Rules Raise your hand if you have a question. Be respectful. When I raise my hand… Share your findings with the people near you. Poke around, experiment, and have fun… Imagine, create, and play!!!
  • 10. Objectives Provide a thorough introduction to the Arduino programming environment. Develop a use of simple functions to interact with the LEDs, light sensor, push button, and buzzer on the Protosnap Pro Mini.
  • 11.
  • 12. Arduino LilyPad Protosnap Dev What is it? What can it do? Who cares?
  • 13. What is it? Heart of it – ATMega328 (a $4 microcontroller) Open Source High tolerance for ESD and “bad” electronics practices… Provides easy way to interact with a computer physically – a.k.a. physical computing
  • 14. What can it do? - Great for prototyping ideas - Great to teach Intro to Programming Arduino (no assembly required!) - Lots and lots of options! - Large pads can be sew- able
  • 15. Who cares? Hackers / Makers Engineers Artists Musicians Kids! Teachers!! You!!!
  • 17. What is all this stuff??? Components Buzzer / Speaker Light Sensor Temp. Sensor the Brain ATmega328 (16 MHz clock)
  • 18. What is all this stuff??? Silk Screen & Pins Actual Pins on Atmega328
  • 19. Startup Arduino IDE Double-click on either the Arduino Icon or wherever you installed (saved) the Arduino program.
  • 21. Lesson #0a – Setting up Arduino 1.Setup Board (LilyPad Arduino w/ ATmega328) 2.Setup COM Port PC – Highest COM # Mac – /dev/tty.usbserial-A####xXx
  • 23. Tools  Serial Port Setup COM Port PC – Highest COM # Mac – /dev/tty.usbserial- A####xxx
  • 27. What is ArduBlock? • Graphical Introduction to Programming • Scratch-like interface • Clear transition to text-based coding • Generates real Arduino code in the background.
  • 28. Block Organization Manipulating or modifying the program flow or behavior. Serial and I2C communication: transferring data between devices & PC Special utilities: Tone, servo, and ultrasonic sensors Creating, assigning, or using constants, variables, or arrays. Simple and complex math operations. Boolean logic operations and comparisons. Reading or setting values (voltages) to pins on the microcontroller.
  • 29. Block Organization Control Manipulating or modifying the program flow or behavior.
  • 30. Pin # – any number from 0 to 19 Values – Pin # – 3, 5, 6, 9, 10, or 11 . Values – Allows the control of the pins on the Atmega328 chip – turning them on or off (like the light switch) Block Organization Pins or to Notice the different shapes? Digital Values Analog (Number) Values
  • 31. Lesson #0b – Test Upload Notes: • Click and drag blocks from the left pane to the Programming Area. • Blocks should snap/click together. • Right-click to copy-paste (clone) a block • Drag blocks back to the left pane to discard. Click Upload to Arduino and watch… Create the following program -- What do you expect this to do?
  • 32. Click back to the Arduino window to check for status messages
  • 33. What do you see? LED on pin #13
  • 34.
  • 35. What about turning the LED off? Click to change the HIGH to a LOW
  • 36. Let’s get to hacking… Lesson #1 – What if I want to Blink? “Hello World” of Physical Computing Psuedo-code – how should this work? Turn LED ON Wait Turn LED OFF Wait Rinse & Repeat
  • 37. Let’s get to hacking… Lesson #1 – What if I want to Blink? “Hello World” of Physical Computing Runs once at the beginning of code. Repeats – continuously over and over and over…
  • 39. What other LEDs can we play with? 16 18 17
  • 40. Pins with an A are actually Analog INPUT pins – but they’re really identified as… Digital Pins are numbered 0 to 13. Analog Input Pins are A0 to A5. but… Analog Pin Digital I/O ID A0  14 A1  15 A2  16 A3  17 A4  18 A5  19 AnalogPinMapping
  • 41. Alright? Let’s blink! Challenge 1a – Blink to mimic a heartbeat Challenge 1b – Blink multiple LEDs First -- plan out a pattern on paper – then start coding Challenge 1c – Multiple LEDS – Knight Rider (Cylon)-esque
  • 42.
  • 43. Save your Project • Save early, Save often! • Enumerate your iterations – (e.g. blink_10.adp, blink_11.adp, blink_12.adp…)
  • 44. Speeding up and Slowing Down… What if we wanted to create a pattern that starts off with a slow blink and gets faster and faster? What part do we need to be able to change? constant
  • 45. Programming Concepts: Using Variables Variable Types: 8 bits 16 bits 32 bits byte char int unsigned int long unsigned long float
  • 46. Using Variables in ArduBlock Numbers/Constants Variable is just a placeholder for a value. This placeholder can be manipulated within the code.
  • 47. Start by setting a variable called delayTime in the setup
  • 48. Now… replace the 1000 in each delay with the variable name
  • 49. Decrement delayTime each loop – using Math Operators
  • 50. Example: Did you come up with something like this?
  • 51. What happens when you reach zero? Let’s find out!
  • 52. Debugging – how can we see what’s going on? Serial Monitor Serial print command Any message “glue” Data
  • 53. Add this block… so that we can watch the variable value
  • 54. Upload & Click back to Arduino Open the Serial Monitor
  • 55. How do we fix / prevent this from happening? If this is TRUE… Do this. Otherwise, do this. Conditional Logic:  If(), If() – else…
  • 56. Logical Operators Comparisons / Conditionals Greater than Less than Equal to Greater than or equal to Less than or equal to Not equal to
  • 57. If delayTime <= 0… reset
  • 58. Advanced… Combinations of inequalities Combine multiple conditions together using or and and Example:
  • 59. Other than just turning an LED on and off… What else might we want to do?
  • 60. Concept: Analog vs. Digital Micro-controllers are digital devices – ON or OFF. An Analog signal is anything that can be a full range of values. xWhat are some examples? Think of like a ramp or a hill.
  • 61. Concept: Analog vs. Digital To create an analog signal, the microcontroller uses a technique called PWM. Pulse Width Modulation (PWM) Pins 3, 5, 6, 9, 10, 11 are capable of producing an Analog Output
  • 62. Color Mixing with 3 LEDs RGB LED Challenge 2a: 1) Experiment with different values – what do you observe happens? Be prepared to share with the class – what did you try, and what did you see? 2) Do you observe anything strange about the behavior? 3) How do you create Orange? Purple? Magenta? LED PINS RED = 9 GREEN = 11 BLUE = 10 Change either of these values… See what happens!
  • 63. Color Mixing with 3 LEDs Tri-color LED The RGB LED is a Common-Anode (means the positive side of the LED is all tied to Vcc). The signal line is connected to the bottom of each LED. Don’t worry - it’s just a different method of completing a circuit! Pin 9 Pin 11 Pin 10 5 V Value = 0 (LOW)  LED is ON Value = 255 (HIGH)  LED is OFF
  • 64. Color Mixing with 3 LEDs Challenge 2b: Experiment with different values of Red, Green, and Blue to create a couple different colors. Write down the values you used. Check these values with www.colorpicker.com Challenge 2c: Create a unique lighting display that blinks, fades, or switches colors. Be prepared to have a name for your art piece and show this to the rest of the class.
  • 67. A Simple Example Try this bit of code. What do you think will happen? Test it and write down your observations. DIG INPUT 2
  • 68. digital Inputs Buttons / Slide Switches INPUT A5 INPUT A5 (a.k.a. 19) What about this?? Analog Pin Digital I/O ID A0  14 A1  15 A2  16 A3  17 A4  18 A5  19 AnalogPinMapping
  • 69. digital Inputs Buttons / Slide Switches Challenge 3a: Re-arrange the blocks or add new ones to: • Blink LED quickly when the button is pressed. • Otherwise blink slow Same as Pin A5
  • 70. digital Inputs Buttons / Slide Switches Challenge 3b: Now, using the button / switch – to start a disco/light changing pattern Challenge 3c: Now, using the button / switch – to turn on and off the VIBE motor.
  • 71. Reading the Light Sensor? What is the biggest and smallest value the analog pin will “measure”? [Hint: open your serial monitor to find out!]
  • 72. Challenge Use the light sensor input to affect the blink rate of the LEDs. Use the light sensor input to affect the speed of a “knight-rider” or cylon display. Use the light sensor to ___________.
  • 73. Save your Project #3 Sensors
  • 74. Making Music Setting up the Speaker Three simple blocks to play with…
  • 75. Making Music Let’s Play a song… Twinkle-Twinkle: CC GG AA G FF EE DD C GG Happy Birthday: G G A G C B G G A G D C G G G E C C B A Hot Cross Buns: B A G <> B A G <> G G G G <> A A A A B A G Mary Had A Little Lamb: B A G A BB B <> AA A <> BB B <> B A G A BBBB AAA BAG.
  • 76. Musical Notes / Frequencies Note Frequency (Hz) C4 261 C# 4/Db 4 277 D4 293 D# 4/Eb 4 311 E4 329 F4 349 F# 4/Gb 4 369 G4 392 G# 4/Ab 4 415 A4 440 A# 4/Bb 4 466 B4 493 Note Frequency (Hz) C5 523 C# 5/Db 5 554 D5 587 D# 5/Eb 5 622 E5 659 F5 698 F# 5/Gb 5 739 G5 783 G# 5/Ab 5 830 A5 880 A# 5/Bb 5 932 B5 987
  • 77. Save your Project #4 Tone
  • 80. SparkFun Tutorials and Projects - GardenBot: www.sparkfun.com/news/598 - High Altitude Balloon: www.sparkfun.com/tutorials/180 - GPS Clock: www.sparkfun.com/tutorials/47 - Earthquake Data Logger: www.sparkfun.com/tutorials/235
  • 81. Thousands of Amazing ideas… The Cat Defender… http://www.plasma2002.com/blenderdefende r/ List of projects at Sparkfun: https://learn.sparkfun.com/tutorials
  • 83. Before leaving, please fill out a quick survey so that I can get your e-mail and a little info about your familiarity with Arduino / Sparkfun. Thanks! http://www.sparkfun.com/WorkshopFeedback Feedback?
  • 84. www.sparkfun.com 6175 Longbow Drive, Suite 200 Boulder, Colorado 80301