Top Banner
living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University [email protected]
13

Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University [email protected].

Jan 17, 2016

Download

Documents

Scarlett Lane
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

living with the lab

Introduction to Arduino Programming

arduino.cc

Gerald RecktenwaldPortland State [email protected]

Page 2: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

references

these notes borrow from . . .– Arduino web site

• http://arduino.cc/en/Guide/Environment• http://arduino.cc/en/Tutorial/HomePage

– Adafruit tutorial #1 and 2• http://www.ladyada.net/learn/arduino/lesson2.html

– Leah Buechley’s Introduction to Arduino• http://web.media.mit.edu/~leah/LilyPad/03_arduino_intro.html

living with the lab

2

Page 3: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

writing and downloading code

living with the lab

3

Page 4: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

running Code while tethered

living with the lab

4

Page 5: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

running code stand-alone

living with the lab

5

Page 6: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

Arduino IDEIDE = Integrated Development Environment

http://www.arduino.cc/en/Guide/Environment

living with the lab

6

Page 7: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

code structure: header

header provides information andcan also contain code

living with the lab

7

Page 8: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

code structure: setup function

setup function is executedonly once at the start

living with the lab

8

Page 9: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

code structure: loop function

loop function isrepeated indefinitely

living with the lab

9

Page 10: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

code

digital I/O functions:• pinMode• digitalWrite• digitalRead

pinMode(13, Output)prepares pin 13 foroutputs of voltage

living with the lab

10

Page 11: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

digitalWrite(13, HIGH)sets pin 13 to a voltage thatmeans “on” (five volts in this case)

living with the lab

11

code

digital I/O functions:• pinMode• digitalWrite• digitalRead

Page 12: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

delay(1000);tells microcontroller to do nothing for 1000 ms = 1 s

code

living with the lab

12

digital I/O functions:• pinMode• digitalWrite• digitalRead

Page 13: Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University gerry@me.pdx.edu.

digitalWrite(13, LOW) sets pin 13 to voltagethat means “off” or zero volts

living with the lab

13

digital I/O functions:• pinMode• digitalWrite• digitalRead

code