Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Coding

Coding

Ratings: (0)|Views: 323|Likes:
Published by towsen

More info:

Published by: towsen on Feb 12, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/11/2013

pdf

text

original

 
Intro to Coding with Arduino
Sunday, February 12, 2012
 
Basic concepts
Sketch
: an Arduino program you copy, modify or create
Compiling
 
: Behind-the-scenes translation of Arduino code into C-language code
void Setup ( )
 
: A “function” Arduino needs defined so that it knows, before it getsstarted doing its tricks, how you are using the input & output pins. It runs
 before
the
Loop
function.
void Loop ( )
 
: Another Arduino function; this one describes the looping (repeated)actions you want the program to perform. It runs until the power is turned off.NOTE: neither
Setup
nor
Loop
return a value, so you have to tell the computerthat they will be “void”
Sunday, February 12, 2012
 
Syntax and Punctuation
Like it or not, you have to be precise with syntax, punctuation and spellingbecause Arduino cannot read your mind!!
 Arduino vocabulary is made up of single words with no spaces; they are often compound words (e.g.digitalWrite
 
), but if you put in a space you will get an error message. Arduino is written in what is called
camel-case
 
: the first letter of each word (except the first word) is capitalized. This is a pretty standard programmingconvention.Each line of code must end with a semi-colon. For example:digitalWrite (13,HIGH);Blocks of code must be placed within curly brackets. For example:void setup ( ) { pinMode (13, OUTPUT); }Blank spaces are generally ignored by Arduino (except in
strings
of text) but it is
case-sensitive
 
.digitalWriteishow it spells that function; if you type inDigitalWriteyou will get an error message.Comment a line (or less) of text by typing
 // 
 before the non-code words. To comment more than a single line of text, type
 /*
before the non-code segment and
*/ 
after it.
Sunday, February 12, 2012

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->