This document provides a cheat sheet for the Arduino microcontroller platform. It summarizes key concepts such as functions, data types, operators, I/O pins, serial communication, and more in a condensed format to serve as a quick reference guide for Arduino programming. Control structures, constants, libraries, analog and digital I/O, interrupts, and other common functions are defined and their purposes outlined concisely. Links are also provided to additional Arduino documentation and community resources.
This document provides a cheat sheet for the Arduino microcontroller platform. It summarizes key concepts such as functions, data types, operators, I/O pins, serial communication, and more in a condensed format to serve as a quick reference guide for Arduino programming. Control structures, constants, libraries, analog and digital I/O, interrupts, and other common functions are defined and their purposes outlined concisely. Links are also provided to additional Arduino documentation and community resources.
J EROEN D OGGEN , AP U NIVERSITY C OLLEGE A NTWERP
Structure Constants Interrupts I/O Pins
void setup() HIGH, LOW attachInterrupt(interrupt, function, type) Uno Mega void loop() INPUT, OUTPUT detachInterrupt(interrupt) # of IO 14 + 6 54 + 11 true, false boolean(interrupt) Serial Pins 3 0 - RX, 1 -TX RX1 RX4 53 : Decimal interrupts() Interrupts 2,3 2,3,18,19,20,21 Control Structures B11010101 : Binary noInterrupts() PWM Pins 5,6 - 9,10 - 3,11 0 13 if(x<5){} 0x5BA4 : Hexadecimal SPI (SS, MOSI, MISO, SCK) 10 13 50 53 for(int i = 0; i < 255 i++ ){} I2C (SDA, SCK) A4, A5 20,21 while((x < 6 ){} Advanced I/O Data Types tone(pin, freqhz) tone(pin, freqhz, duration_ms) Analog I/O void Further Syntax boolean 0, 1, false, true noTone(pin) analogReference(EXTERNAL, INTERNAL) // Single line comment char e.g. a -128 127 shiftOut (dataPin, clockPin, how, value) analogRead(pin) / .. / Multi line comment unsigned char 0 255 unsigned long pulseIn(pin, [HIGH,LOW]) analogWrite(pin) #define ANSWER 42 int -32.768 32.767 #include <myLib.h> unsigned int 0 65535 long -2.147.483.648 2.147.483.647 Time Digital I/O float -3,4028235E+38 3.402835E+38 unsigned long millis() 50 days overflow pinMode(pin,[INPUT,OUTPUT]) General Operators sizeof (myint) returns 2 bytes unsigned long micros() 70 min overflow digitalWrite(pin, value) delay(ms) int analogRead(pin) = assignment delayMicroseconds(us) +, addition, substraction Arrays , / multiplication, division Serial Communication int myInts[6]; % modulo int myPins[]=2,4,8,5,6; Math == equal to Serial.begin(speed) != not equal to int myVals[6]=2,-4,9,3,5; min(x,y) max(x,y) abs(x) Serial.print(Text) < less than sin(rad) cos(rad) tan(rad) Serial.println(Text) <= less than or equal to pow(base, exponent) Strings map(val, fromL, fromH, toL, toH) char S1[15]; constrain(val, fromL, toH) Websites Pointer Access char S2[8]=A,r,d,u,i,n,o; forum.arduino.cc char S3[8]=A,r,d,u,i,n,o,\0; playground.arduino.cc & reference operator char S4[]=Arduino; Pseudo Random Numbers dereference operator arduino.cc/en/Reference char S5[8] = Arduino; randomSeed(seed) char S6[15] = Arduino; long random(max) Bitwise Operators long random(min, max) Arduino Uno Board & bitwise AND Conversion | bitwise OR char() int() long() ATmega328 Pinout bitwise XOR bitwise NOT byte() word() float()
Compound Operators Qualifiers
++ Increment static Persist between calls Decrement volatile Use RAM (nice for ISR) += Compound addition const Mark read-only &= Compound bitwise AND PROGMEM Use flash memory
Download Full The Routledge International Handbook of Spirituality in Society and the Professions 1st Edition Laszlo Zsolnai And Bernadette Flanagan (Editors) PDF All Chapters