SlideShare ist ein Scribd-Unternehmen logo
1 von 107
Downloaden Sie, um offline zu lesen
Engineering the
Engineering: Connecting
the Why to the How

Unleashing Your Students'
Inner Inventor—Robots,
Video Games, and DIY!

Brian Huang
Education Engineer
Email: brian.huang@sparkfun.com
Twitter: @bri_huang
#sparkfun
Engineering the
Engineering: Connecting
the Why to the How

Brian Huang
Education Engineer
@bri_huang
#sparkfun
Write this down…
http://bit.ly/SparkFunNSTADenver2013
A little background
(Ignite style)
Ignite presentation format: (a.k.a. Pecha
Kucha)
•
•
•
•

20 Slides
15 seconds per slide
Slides are on auto-advance
Total Time: 5 minutes
About us...
Founded in 2003 by Nathan Seidle.
At SparkFun, our focus is all about creation, innovation,
and sharing information.
Open Source Hardware is at the core of our business. We
emphasize researching, re-mixing, adapting, making
improvements, and sharing with the world!
Today
You will use a microcontroller &
ArduBlock to design, develop, and
build interactivity and “intelligence”
with digital electronics, LEDs, and
sensors.
Consumers

Creators / Makers
Engineers / Inventors
Maker Culture
Make to Learn
Seymour Papert &
Constructionism
I want ________ to ________.
Introducing Arduino…
(circa 2005) Small, low-cost micro-controller (mini-computer).

Describes both the hardware (board) and the programming language.
Developed off the Atmel ATMega328 chip.
Designed with Artists, Students, and Non-Engineers in mind…
But, really… what is this “arduino?”
In science???
• Data logging / collection
• Control of motors, LEDs, experiments
• Design of atmospheric and Space-based
experiments and apparatus
• Inventions!
• Making Art!!!
A few project ideas
And, a couple more...
And, a couple more...
Whew!

Questions?
Let’s Start!
First thing you need is…
Download Arduino from:
www.arduino.cc/download
Follow their directions on installation.
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
A little short-cut…

Unzip this file to your Arduino
sketchbook folder.
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!!!
What is all this stuff???
Components

the Brain
ATmega328
(16 MHz clock)

Temp.
Sensor

Light
Sensor
Buzzer /
Speaker
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.usbserialA####xxx
Other Board Types
Tools  ArduBlock
Load ArduBlock
Zoomed out
View

Programming
Blocks Palate

Programming
Area
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.
Reading or setting values (voltages) to
pins on the microcontroller.
Boolean logic operations and
comparisons.
Simple and complex math operations.

Creating, assigning, or using constants,
variables, or arrays.
Special utilities: Tone, servo, and
ultrasonic sensors
Serial and I2C communication:
transferring data between devices & PC
Block Organization

Control
Manipulating or modifying the program
flow or behavior.
Example #1
Click back to the Arduino window to
check for status messages
Example #1 - debrief
What is the difference between setup() and
loop()?
When you add multiple blink blocks, describe
the behavior of the LEDs?
What new feature might you want to create?
Example #2
See if you can come up with the steps needed
to make an LED blink.
What other LEDs can we play
with?

16

18

17
Pins with an A are Analog INPUT pins –
but they’re really identified as…
Digital Pins are numbered 0 to 13.

Analog Pin Mapping

Analog Input Pins are A0 to A5. but, actually…
Analog Pin

Digital I/O ID

A0



14

A1
A2
A3
A4
A5







15
16
17
18
19
Example #2 - debrief
1) Can you write a program that blinks on and off with a 1 second
delay in between? What is the period of this pattern?
2) Can you write a program that blinks 10 times per second? What
delay time did you use? What about 50 times per second? What
delay time did you use?
3) Creative: Modify your program to create a heartbeat pattern.

4) Extension: Add extra LEDs to create an LED chaser or Larson
Scanner. Use as many of the LEDs on the Lilypad Development
Board as you like. How fast do you want it to run?
set digital pin
Allows the control of the pins on the Atmega328
chip – turning them on or off (like the light
switch)

Different shapes?
Any number… except,
Pin# is limited to a
range of:

or
ON

OFF

Digital Constant Block

to
Numeric Constant Block
Example #3 - What’s next?
set analog pin
Allows the control of the pins on the Atmega328
chip – turning them partially on or partially off
(like a dimmer switch)
Because of certain hardware
settings, set analog pin only
works with pins 3, 5, 6, 9, 10,
& 11.
Rather than having just HIGH
and LOW, you can set the
pin to any value from 0 to
255.

Analog Output Values

to
Concept: Analog vs. Digital
To create an analog signal, the
microcontroller uses a technique called
PWM.
Pins 3, 5, 6, 9, 10, 11 are capable of producing an
Analog Output
Pulse Width Modulation (PWM)
Example 4 - What about sensors?
Example #4 - debrief
What was the maximum value you saw from the light
sensor?
What was the maximum value you saw from the temp
sensor?
Analog sensors are read by a 10-bit Analog to Digital
(AD) converter. It “quantizes” a voltage at the input
pin into 1023 “bins.” 5 V = 1023 and 0 V = 0.
Example #5 – if statements
Example #6 – making sounds
(er… music)
Options, options, options…

Questions
?
Preview of Digital SandBox
Temp Sensor
Light Sensor

Microphone

Arduino

Push Button
LED Array
RGB LED
Motor /
Speaker Out

Switch

Slider / Potentiometer
Extension Project
Create a musical and interactive lighting
display.
Plan out what you want the project to do,
first! Use an outline, flow-chart, or thinking
map to accomplish this.
Getting started with Arduino
SparkFun Inventor’s Kit
KIT-12001
Circuit 1: Blinking an LED
Circuit 2: Reading a Potentiometer
Circuit 3: Driving and RGB LED
Circuit 4: Driving Multiple LEDs
Circuit 5: Push Buttons
Circuit 6: Reading a Photo Resistor
Circuit 7: Reading a Temperature Sensor
Circuit 8: Driving a Servo Motor
Circuit 9: Using a Flex Sensor
Circuit 10: Reading a Soft Potentiometer
Circuit 11: Using a Buzzer
Circuit 12: Driving a Motor
Circuit 13: Using Relays
Circuit 14: Using a Shift Register
Circuit 15: Using an LCD
Data Collection with Vernier
Discount / Promo Code
Promo Code: EDUNSTA2013
25% Discount – orders > $30
E-mail: education@sparkfun.com to create
an educator account.
Twitter: @bri_huang, #sparkfun, #nsta2013
Thank you!
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
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
Variables  placeholders / reminder for
counting
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?
Conditional Logic:  If(), If() – else…
If this is TRUE…

Do this.

Otherwise,
do this.
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 / control?
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.
Pins 3, 5, 6, 9, 10, 11 are capable of producing an
Analog Output
Pulse Width Modulation (PWM)
Color Mixing with 3 LEDs

RGB LED

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).
5V

The signal line is connected to the bottom of each
LED.
Don’t worry - it’s just a different method of
completing a circuit!
Value = 0 (LOW)  LED is ON
Value = 255 (HIGH)  LED is OFF
Pin
9

Pin
11

Pin
10
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

DIG
INPUT 2

Try this bit of code.
What do you think will happen? Test it
and write down your observations.
digital Inputs

Buttons / Slide Switches

Analog Pin Mapping

What about
this??
Analog Pin

Digital I/O ID

A0



14

A1
A2
A3
A4
A5







15
16
17
18
19

INPUT A5
INPUT A5
(a.k.a. 19)
digital Inputs

Buttons / Slide Switches
Same as
Pin A5

Challenge 3a:
Re-arrange the blocks or add new ones to:
• Blink LED quickly when the button is pressed.
• Otherwise blink slow
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:
GGAGCBGGAGDCGGGECCBA

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)

Note

Frequency (Hz)

C4
C#4/Db4
D4
D#4/Eb4
E4
F4
F#4/Gb4
G4
G#4/Ab4
A4
A#4/Bb4
B4

261
277
293
311
329
349
369
392
415
440
466
493

C5
C#5/Db5
D5
D#5/Eb5
E5
F5
F#5/Gb5
G5
G#5/Ab5
A5
A#5/Bb5
B5

523
554
587
622
659
698
739
783
830
880
932
987
Save your Project #4
Tone
NSTA 2013 Denver - ArduBlock and Arduino

Weitere ähnliche Inhalte

Was ist angesagt?

Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full Tutorial
Akshay Sharma
 
The arduino uno is a microcontroller board based on the
The arduino uno is a microcontroller board based on theThe arduino uno is a microcontroller board based on the
The arduino uno is a microcontroller board based on the
Pramod Kumar
 
Arduino as an embedded industrial controller
Arduino as an embedded industrial controllerArduino as an embedded industrial controller
Arduino as an embedded industrial controller
Jose Luis Poza Luján
 
Introducing... Arduino
Introducing... ArduinoIntroducing... Arduino
Introducing... Arduino
zvikapika
 

Was ist angesagt? (20)

Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hq
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full Tutorial
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Arduino tutorial A to Z
Arduino tutorial A to ZArduino tutorial A to Z
Arduino tutorial A to Z
 
Getting Started With Arduino_Tutorial
Getting Started With Arduino_TutorialGetting Started With Arduino_Tutorial
Getting Started With Arduino_Tutorial
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
The arduino uno is a microcontroller board based on the
The arduino uno is a microcontroller board based on theThe arduino uno is a microcontroller board based on the
The arduino uno is a microcontroller board based on the
 
Arduino: Tutorial de Arduino
Arduino: Tutorial de ArduinoArduino: Tutorial de Arduino
Arduino: Tutorial de Arduino
 
Arduino Day 1 Presentation
Arduino Day 1 PresentationArduino Day 1 Presentation
Arduino Day 1 Presentation
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the Arduino
 
Arduino Model's
Arduino Model'sArduino Model's
Arduino Model's
 
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino Programming
 
Arduino technical session 1
Arduino technical session 1Arduino technical session 1
Arduino technical session 1
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Ardui no
Ardui no Ardui no
Ardui no
 
Arduino as an embedded industrial controller
Arduino as an embedded industrial controllerArduino as an embedded industrial controller
Arduino as an embedded industrial controller
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Introducing the Arduino
Introducing the ArduinoIntroducing the Arduino
Introducing the Arduino
 
Introducing... Arduino
Introducing... ArduinoIntroducing... Arduino
Introducing... Arduino
 

Ähnlich wie NSTA 2013 Denver - ArduBlock and Arduino

Ähnlich wie NSTA 2013 Denver - ArduBlock and Arduino (20)

What is arduino
What is arduinoWhat is arduino
What is arduino
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
 
Arduino - Learning.pdf
Arduino - Learning.pdfArduino - Learning.pdf
Arduino - Learning.pdf
 
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slides
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to 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
arduinoarduino
arduino
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10
 
Prototyping Embedded Devices_Internet of Things
Prototyping Embedded Devices_Internet of ThingsPrototyping Embedded Devices_Internet of Things
Prototyping Embedded Devices_Internet of Things
 
Arduino
Arduino Arduino
Arduino
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
 
13223971.ppt
13223971.ppt13223971.ppt
13223971.ppt
 
SKAD Electronics Training Manual.pdf
SKAD Electronics Training Manual.pdfSKAD Electronics Training Manual.pdf
SKAD Electronics Training Manual.pdf
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
IEEE College of Technology MAES SE 2020 - Coding Fun
IEEE College of Technology MAES SE 2020 - Coding FunIEEE College of Technology MAES SE 2020 - Coding Fun
IEEE College of Technology MAES SE 2020 - Coding Fun
 
Hello Arduino.
Hello Arduino.Hello Arduino.
Hello Arduino.
 
Industrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder LogicIndustrial Applications of Arduino using Ladder Logic
Industrial Applications of Arduino using Ladder Logic
 

Mehr von Brian Huang

Mehr von Brian Huang (7)

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)
 
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
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

NSTA 2013 Denver - ArduBlock and Arduino

  • 1. Engineering the Engineering: Connecting the Why to the How Unleashing Your Students' Inner Inventor—Robots, Video Games, and DIY! Brian Huang Education Engineer Email: brian.huang@sparkfun.com Twitter: @bri_huang #sparkfun
  • 2. Engineering the Engineering: Connecting the Why to the How Brian Huang Education Engineer @bri_huang #sparkfun
  • 4. A little background (Ignite style) Ignite presentation format: (a.k.a. Pecha Kucha) • • • • 20 Slides 15 seconds per slide Slides are on auto-advance Total Time: 5 minutes
  • 5.
  • 6.
  • 7. About us... Founded in 2003 by Nathan Seidle. At SparkFun, our focus is all about creation, innovation, and sharing information. Open Source Hardware is at the core of our business. We emphasize researching, re-mixing, adapting, making improvements, and sharing with the world!
  • 8.
  • 9.
  • 10. Today You will use a microcontroller & ArduBlock to design, develop, and build interactivity and “intelligence” with digital electronics, LEDs, and sensors.
  • 11.
  • 15. I want ________ to ________.
  • 16. Introducing Arduino… (circa 2005) Small, low-cost micro-controller (mini-computer). Describes both the hardware (board) and the programming language. Developed off the Atmel ATMega328 chip. Designed with Artists, Students, and Non-Engineers in mind…
  • 17. But, really… what is this “arduino?”
  • 18. In science??? • Data logging / collection • Control of motors, LEDs, experiments • Design of atmospheric and Space-based experiments and apparatus • Inventions! • Making Art!!!
  • 19. A few project ideas
  • 20. And, a couple more...
  • 21. And, a couple more...
  • 22.
  • 25. First thing you need is… Download Arduino from: www.arduino.cc/download Follow their directions on installation.
  • 26.
  • 27.
  • 28. 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
  • 29. A little short-cut… Unzip this file to your Arduino sketchbook folder.
  • 30. 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!!!
  • 31.
  • 32. What is all this stuff??? Components the Brain ATmega328 (16 MHz clock) Temp. Sensor Light Sensor Buzzer / Speaker
  • 33. What is all this stuff??? Silk Screen & Pins Actual Pins on Atmega328
  • 34. Startup Arduino IDE Double-click on either the Arduino Icon or wherever you installed (saved) the Arduino program.
  • 36. 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
  • 38. Tools  Serial Port Setup COM Port PC – Highest COM # Mac – /dev/tty.usbserialA####xxx
  • 42. What is ArduBlock? • • • • Graphical Introduction to Programming Scratch-like interface Clear transition to text-based coding Generates real Arduino code in the background.
  • 43. Block Organization Manipulating or modifying the program flow or behavior. Reading or setting values (voltages) to pins on the microcontroller. Boolean logic operations and comparisons. Simple and complex math operations. Creating, assigning, or using constants, variables, or arrays. Special utilities: Tone, servo, and ultrasonic sensors Serial and I2C communication: transferring data between devices & PC
  • 44. Block Organization Control Manipulating or modifying the program flow or behavior.
  • 46. Click back to the Arduino window to check for status messages
  • 47. Example #1 - debrief What is the difference between setup() and loop()? When you add multiple blink blocks, describe the behavior of the LEDs? What new feature might you want to create?
  • 48.
  • 49. Example #2 See if you can come up with the steps needed to make an LED blink.
  • 50. What other LEDs can we play with? 16 18 17
  • 51. Pins with an A are Analog INPUT pins – but they’re really identified as… Digital Pins are numbered 0 to 13. Analog Pin Mapping Analog Input Pins are A0 to A5. but, actually… Analog Pin Digital I/O ID A0  14 A1 A2 A3 A4 A5      15 16 17 18 19
  • 52. Example #2 - debrief 1) Can you write a program that blinks on and off with a 1 second delay in between? What is the period of this pattern? 2) Can you write a program that blinks 10 times per second? What delay time did you use? What about 50 times per second? What delay time did you use? 3) Creative: Modify your program to create a heartbeat pattern. 4) Extension: Add extra LEDs to create an LED chaser or Larson Scanner. Use as many of the LEDs on the Lilypad Development Board as you like. How fast do you want it to run?
  • 53. set digital pin Allows the control of the pins on the Atmega328 chip – turning them on or off (like the light switch) Different shapes? Any number… except, Pin# is limited to a range of: or ON OFF Digital Constant Block to Numeric Constant Block
  • 54. Example #3 - What’s next?
  • 55. set analog pin Allows the control of the pins on the Atmega328 chip – turning them partially on or partially off (like a dimmer switch) Because of certain hardware settings, set analog pin only works with pins 3, 5, 6, 9, 10, & 11. Rather than having just HIGH and LOW, you can set the pin to any value from 0 to 255. Analog Output Values to
  • 56. Concept: Analog vs. Digital To create an analog signal, the microcontroller uses a technique called PWM. Pins 3, 5, 6, 9, 10, 11 are capable of producing an Analog Output Pulse Width Modulation (PWM)
  • 57. Example 4 - What about sensors?
  • 58. Example #4 - debrief What was the maximum value you saw from the light sensor? What was the maximum value you saw from the temp sensor? Analog sensors are read by a 10-bit Analog to Digital (AD) converter. It “quantizes” a voltage at the input pin into 1023 “bins.” 5 V = 1023 and 0 V = 0.
  • 59. Example #5 – if statements
  • 60. Example #6 – making sounds (er… music)
  • 62. Preview of Digital SandBox Temp Sensor Light Sensor Microphone Arduino Push Button LED Array RGB LED Motor / Speaker Out Switch Slider / Potentiometer
  • 63. Extension Project Create a musical and interactive lighting display. Plan out what you want the project to do, first! Use an outline, flow-chart, or thinking map to accomplish this.
  • 65. SparkFun Inventor’s Kit KIT-12001 Circuit 1: Blinking an LED Circuit 2: Reading a Potentiometer Circuit 3: Driving and RGB LED Circuit 4: Driving Multiple LEDs Circuit 5: Push Buttons Circuit 6: Reading a Photo Resistor Circuit 7: Reading a Temperature Sensor Circuit 8: Driving a Servo Motor Circuit 9: Using a Flex Sensor Circuit 10: Reading a Soft Potentiometer Circuit 11: Using a Buzzer Circuit 12: Driving a Motor Circuit 13: Using Relays Circuit 14: Using a Shift Register Circuit 15: Using an LCD
  • 67. Discount / Promo Code Promo Code: EDUNSTA2013 25% Discount – orders > $30 E-mail: education@sparkfun.com to create an educator account. Twitter: @bri_huang, #sparkfun, #nsta2013
  • 68. Thank you! 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
  • 69. 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
  • 70.
  • 71. Save your Project • Save early, Save often! • Enumerate your iterations – (e.g. blink_10.adp, blink_11.adp, blink_12.adp…)
  • 72. 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
  • 73. Programming Concepts: Using Variables Variables  placeholders / reminder for counting
  • 74. Using Variables in ArduBlock Numbers/Constants Variable is just a placeholder for a value. This placeholder can be manipulated within the code.
  • 75. Start by setting a variable called delayTime in the setup
  • 76. Now… replace the “1000” in each delay with the variable name
  • 77. Decrement delayTime each loop – using Math Operators
  • 78. Example: Did you come up with something like this?
  • 79. What happens when you reach zero? Let’s find out!
  • 80. Debugging – how can we see what’s going on? Serial Monitor Serial print command Any message “glue” Data
  • 81. Add this block… so that we can watch the variable value
  • 82. Upload & Click back to Arduino Open the Serial Monitor
  • 83. How do we fix / prevent this from happening? Conditional Logic:  If(), If() – else… If this is TRUE… Do this. Otherwise, do this.
  • 84. Logical Operators Comparisons / Conditionals Greater than Less than Equal to Greater than or equal to Less than or equal to Not equal to
  • 85. If delayTime <= 0… reset
  • 86. Advanced… Combinations of inequalities Combine multiple conditions together using or and and Example:
  • 87. Other than just turning an LED on and off… What else might we want to do / control?
  • 88. 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.
  • 89. Concept: Analog vs. Digital To create an analog signal, the microcontroller uses a technique called PWM. Pins 3, 5, 6, 9, 10, 11 are capable of producing an Analog Output Pulse Width Modulation (PWM)
  • 90. Color Mixing with 3 LEDs RGB LED LED PINS RED = 9 GREEN = 11 BLUE = 10 Change either of these values… See what happens!
  • 91. 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). 5V The signal line is connected to the bottom of each LED. Don’t worry - it’s just a different method of completing a circuit! Value = 0 (LOW)  LED is ON Value = 255 (HIGH)  LED is OFF Pin 9 Pin 11 Pin 10
  • 92. 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.
  • 93.
  • 96. A Simple Example DIG INPUT 2 Try this bit of code. What do you think will happen? Test it and write down your observations.
  • 97. digital Inputs Buttons / Slide Switches Analog Pin Mapping What about this?? Analog Pin Digital I/O ID A0  14 A1 A2 A3 A4 A5      15 16 17 18 19 INPUT A5 INPUT A5 (a.k.a. 19)
  • 98. digital Inputs Buttons / Slide Switches Same as Pin A5 Challenge 3a: Re-arrange the blocks or add new ones to: • Blink LED quickly when the button is pressed. • Otherwise blink slow
  • 99. 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.
  • 100. Reading the Light Sensor? What is the biggest and smallest value the analog pin will “measure”? [Hint: open your serial monitor to find out!]
  • 101. 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 ___________.
  • 102. Save your Project #3 Sensors
  • 103. Making Music Setting up the Speaker Three simple blocks to play with…
  • 104. Making Music Let’s Play a song… Twinkle-Twinkle: CC GG AA G FF EE DD C GG Happy Birthday: GGAGCBGGAGDCGGGECCBA 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.
  • 105. Musical Notes / Frequencies Note Frequency (Hz) Note Frequency (Hz) C4 C#4/Db4 D4 D#4/Eb4 E4 F4 F#4/Gb4 G4 G#4/Ab4 A4 A#4/Bb4 B4 261 277 293 311 329 349 369 392 415 440 466 493 C5 C#5/Db5 D5 D#5/Eb5 E5 F5 F#5/Gb5 G5 G#5/Ab5 A5 A#5/Bb5 B5 523 554 587 622 659 698 739 783 830 880 932 987
  • 106. Save your Project #4 Tone