0% found this document useful (0 votes)
2 views1 page

NewArduinoCheatsheet 1

The Arduino Quick Reference Cheatsheet provides essential functions and syntax for programming Arduino, including program flow, pin configuration, data types, and basic logic. It outlines key commands for setting up inputs and outputs, reading sensor values, and performing mathematical operations. Additionally, it includes information on communication, looping, comments, and library usage.

Uploaded by

firststudent
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

NewArduinoCheatsheet 1

The Arduino Quick Reference Cheatsheet provides essential functions and syntax for programming Arduino, including program flow, pin configuration, data types, and basic logic. It outlines key commands for setting up inputs and outputs, reading sensor values, and performing mathematical operations. Additionally, it includes information on communication, looping, comments, and library usage.

Uploaded by

firststudent
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Arduino Quick Reference Cheatsheet

For more information visit: http://arduino.cc/Reference/

Program Flow / Control Pin Configuration - INPUT vs OUTPUT Data \ Variable Types
/* Each Arduino Sketch must contain the pinMode(pin, INPUT/OUTPUT/INPUT_PULLUP); const (indicates a constant data type)
following two functions */ void (null data type)
OUTPUT Control int (integer -32,768 to 32,767)
void setup() float (floating point / decimal numbers)
digitalWrite(pin, val); // val: HIGH or LOW arrayName[] – list of elements (any type)
{
analogWrite(pin, val); // val: 0 to 255. String (array of characters)
// runs only once.
}
tone(pin, freq); // freq in Hertz
void loop() System constants / functions
tone(pin, freq, duration); //duration in ms
{
noTone(pin); // stop tone on pin HIGH / LOW
// runs repeatedly.
OUTPUT / INPUT / INPUT_PULLUP
}
Reading INPUTs millis(); //returns # of milliseconds
delay(time_millis); // pauses program in ms buttonPress = digitalRead(pin); // any pin micros(); //returns # of microseconds
delayMicroseconds(time_micros); //pause s sensorVal = analogRead(pin); // A0-A5 pins

Basic Logic Math Operators


Communication
= // assignment
Simple if()-else Serial.begin(baudrate); + // addition
Serial.print(“”); // print data out - // subtraction
if(condition) Serial.println(“”); // print with new line
{ * // multiplication
//true condition code here / // division
x = Serial.read(); // reads a single byte % // modulus
} // data
else x = Serial.parseInt(); // read the next
{ // available integer Logic Operators
//false statement code here == // is equal to?
} Looping != // is not equal to?
----------------- while(condition) < // less than
Compound if()-else if()-else { > // greater than
} <= // less than or equal
if(condition1) >= // greater than or equal
for(init; condition; update variable)
{ && // compound AND
{
//true condition1 code here || // compound OR
}
} ! // NOT (inverse)
else if(condition2)
{ Comments/Debug
//true condition2 code here /* this is a multiline comment. nothing Libraries
} between here will be run or executed */ #include <libraryName.h>
else
{ // this is a single libraryName objectName;
//false statement code here // line comment
} // read library documentation for usage.
rev. 0.2

You might also like