For more information visit: http://arduino.cc/en/Reference/
Structure Digital I/O Data Types
/* Each Arduino sketch must contain the digitalWrite(pin, val); void // nothing is returned following two functions. */ /* val = HIGH or LOW write a HIGH or a LOW boolean // 0, 1, false, true void setup() value to a digital pin. */ char // 8 bits: ASCII character { int var = digitalRead(pin); byte // 8 bits: 0 to 255, unsigned /* this code runs once at the beginning of /* Reads the value from a specified digital int // 16 bits: 32,768 to 32,767, signed the code execution. */ pin, either HIGH or LOW. */ long /* 32 bits: 2,147,483,648 } to 2,147,483,647, signed */ Analog I/O float // 32 bits, signed decimal void loop() analogWrite(pin, val); { /* Writes an analog value to a pin. Constants /* this code runs repeatedly over and over val = integer value from 0 to 255 */ HIGH \ LOW as long as the board is powered. */ int var = analogRead(pin); INPUT \ OUTPUT } /* Reads the value from the specified analog pin. */ true \ false Comments Advanced I/O Mathematical Operators // this is a single line tone(pin, freq); = // assignment /* this is /* Generates a square wave of the specified + // addition a multiline */ frequency to a pin. Pin must be one of the - // subtraction PWM (~) pins. */ * // multiplication Setup tone(pin, freq, duration); / // division pinMode(pin, [INPUT \ OUTPUT \ INPUT_PUL- /* Generates a square wave of the specified % // modulus LUP]); frequency to a pin for a duration in /* Sets the mode of the digital I/O pin. milliseconds. Pin must be one of the PWM (~) It can be set as an input, output, or an pins. */ Logical Operators input with an internal pull-up resistor. noTone(pin); == // boolean equal to */ // Turns off the tone on the pin. != // not equal to < // less than Control Structures Time > // greater than if(condition) delay(time_ms); <= // less than or equal to { /* Pauses the program for the amount of time >= // greater than or equal to // if condition is TRUE, do something here (in milliseconds). */ && // Boolean AND } delayMicroseconds(time_us); || // Boolean OR else /* Pauses the program for the amount of time ! // Boolean NOT { (in microseconds). */ // otherwise, do this millis(); Bitwise Operators } /* Returns the number of milliseconds since & // bitwise AND the board began running the current program. max: 4,294,967,295 */ | // bitwise OR for(initialization; condition; increment) ^ // bitwise XOR { micros(); /* Returns the number of microseconds since ~ // bitwise INVERT // do this the board began running the current program. var << n // bitwise shift left by n bits } max: 4,294,967,295 */ var >> n // bitwise shift right by n bits /* The ‘for’ statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually Libraries used to increment and terminate the loop. #include <libraryname.h> */ /* this provides access to special additional functions for things such as servo motors, SD card, wifi, or bluetooth. */