APPENDIX I - PROGRAMMING REFERENCE
MINIMUM SKETCH DIGITAL INPUT/OUTPUT
void setup( ) pinMode ( pin, INPUT/OUTPUT );
{ } // run once:
void loop( ) digitalWrite ( pin, HIGH,LOW );
{ } // run repeatedly: int = digitalRead ( pin );
SERIAL COMMUNICATIONS ANALOG INPUT/OUTPUT
pinMode ( pin,OUTPUT );
[Link] ( baudrate );
analogWrite ( pin, 0-255 );
[Link] ( );
[Link] ( “ “ ); //text
int = analogRead ( pin );
CONTROL STRUCTURE RANDOM, MAPPING, TONE
if ( condition ) { Action A } random(min, max);
else
{ Action B } map(val, fromL, fromH, toL, toH);
for (int i=0; i <= 255; i++) tone(pin, freqhz ,duration_ms);
{ } noTone(pin);
GENERAL OPERATORS DATA TYPES
= (assignment operator) int (-32,768 to 32,767)
+ (addition) - (subtraction) unsigned int (0 to 65535)
* (multiplication) / (division) oat (-3.4028235E+38 to
% (modulo) 3.4028235E+38)
== (equal to) != (not equal to) double (currently same as oat)
< (less than) > (greater than) boolean (0, 1, false, true)
<= (less than or equal to) char (e.g. ‘a’ -128 to 127)
>= (greater than or equal to) byte (0 to 255)
&& (and) || (or) ! (not)
106