284x Filetype PDF File size 0.36 MB Source: engineering.nyu.edu
arduino
programming
notebook
brian w. evans
Arduino Programming Notebook
Written and compiled by Brian W. Evans
With information or inspiration taken from:
http://www.arduino.cc
http://www.wiring.org.co
http://www.arduino.cc/en/Booklet/HomePage
http://cslibrary.stanford.edu/101/
Including material written by:
Paul Badger
Massimo Banzi
Hernando Barragán
David Cuartielles
Tom Igoe
Daniel Jolliffe
Todd Kurt
David Mellis
and others
Published:
First Edition August 2007
Second Edition September 2008
12c bao
This work is licensed under the Creative Commons
Attribution-Share Alike 2.5 License.
To view a copy of this license, visit:
http://creativecommons.org/licenses/by-sa/2.5/
Or send a letter to:
Creative Commons
171 Second Street, Suite 300
San Francisco, California, 94105, USA
contents
structure
structure 7
setup() 7
loop() 7
functions 8
{} curly braces 8
; semicolon 9
/*… */ block comments 9
// line comments 9
variables
variables 10
variable declaration 10
variable scope 11
datatypes
byte 12
int 12
long 12
float 12
arrays 13
arithmetic
arithmetic 14
compound assignments 14
comparison operators 15
logical operators 15
constants
constants 16
true/false 16
high/low 16
input/output 16
flow control
if 17
if… else 18
for 19
while 20
do… while 20
digital i/o
pinMode(pin, mode) 21
digitalRead(pin) 22
digitalWrite(pin, value) 22
analog i/o
analogRead(pin) 23
analogWrite(pin, value) 23
time
delay(ms) 24
millis() 24
math
min(x, y) 24
max(x, y) 24
random
randomSeed(seed) 25
random(min, max) 25
serial
Serial.begin(rate) 26
Serial.println(data) 26
appendix
digital output 29
digital input 30
high current output 31
pwm output 32
potentiometer input 33
variable resistor input 34
servo output 35
no reviews yet
Please Login to review.