0% found this document useful (0 votes)
13 views

Arduino QRC v2 - 1

This document provides a quick reference for the Arduino programming language and microcontroller. It outlines the basic syntax, variables, data types, operators, and input/output components used in Arduino.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Arduino QRC v2 - 1

This document provides a quick reference for the Arduino programming language and microcontroller. It outlines the basic syntax, variables, data types, operators, and input/output components used in Arduino.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Arduino Quick Reference Card

version 2.1, 20 Mar 2019 by Ernest Neijenhuis PA3HCM

Structure Comparison operators


// declarations and includes == (equal to)
void setup() { != (not equal to)
// this will run once at program startup. < (less than)
} > (greater than)
void loop() { => (greater than or equal to)
// this will be repeated until reset or <= (less than or equal to)
// power is removed.
} Control structures
if( condition ){ }
Syntax else if( condition ){ }
// This is a single line comment. else { }
This will execute the code between the curly brackets if
/* the condition is true, and if not it will test the else if
This is a condition if that is also false the else code will execute.
multiline if(i>5){
comment. digitalWrite(LED_BUILDIN, HIGH);
*/ } else {
digitalWrite(LED_BUILDIN, LOW);
{} - Code is grouped by enclosing it in curly brackets. }
; - Each line of code ends with a semicolon.
for(int i=0; i < #repeats; i++){ }
Constants Used to repeat a chunk of code a number of times (can
#define ledPin 13 count up i++ or down i-- or use any variable), e.g.:
The Arduino IDE has some built-in constants: for(int i=0; i<10; i++){
INPUT INPUT_PULLUP OUTPUT LED_BUILDIN digitalWrite(LED_BUILDIN, HIGH);
HIGH LOW true false delay(1000);
digitalWrite(LED_BUILDIN, LOW);
Include library’s or other code delay(1000);
#include <myLibrary.h> }

Variables delay(time);
byte A single byte (8 bits) value, 0 to 255. Causes a delay of time milliseconds.
int Integer, stores a number in 2 bytes (16 bits).
Has no decimal places and will store a value Digital
between -32,768 and 32,767. pinMode(pin, mode);
long Used when an integer is not large enough. Takes Used to set a pin's mode, pin is the pin number you
4 bytes (32 bits) of RAM and has a range from would like to address 0-19 (analog 0-5 are 14-19). The
-2,147,483,648 to 2,147,483,647. mode can either be INPUT or OUTPUT.
boolean A simple true or false variable. Useful
because it only uses one bit of RAM. digitalWrite(pin, value);
float Used for floating point math (decimals). Takes 4 Once a pin is set as an OUTPUT, it can be set either HIGH
bytes (32 bits) of RAM and has a range from (pulled to +5 volts) or LOW (pulled to ground).
-3.4028235E+38 to 3.4028235E+38.
char Character, stores one character using the ASCII int digitalRead(pin);
code (ie 'A' = 65). Uses one byte (8 bits) of RAM. Once a pin is set as an INPUT you can use this to return
Arduino handles strings as an array of char’s. whether it is HIGH (pulled to +5 volts) or LOW (pulled to
ground).
int Number = 4;
long Counter = 1000000000000000000000000; Analog
boolean gotcha = true; analogWrite(pin, value);
float pi = 3.1415927; Some of the Arduino's pins support pulse width
char userinput = ‘B’; modulation, which is basically a block wave signal. This
char hw[13] = “Hello, world”; function controls its duty cycle: 0 = 0% duty cycle, 255
= 100% duty cycle. You can use this to control a servo,
Arithmatic operators or to control the brightness of an LED.
= (assignment) assigns a value
% (modulo) gives the remainder when one int analogRead(pin);
number is divided by another Returns the input value of an analog pin. A value
+ (addition) between 0 (for 0 volts) and 1024 (for 5 volts) will be
- (subtraction) returned.
* (multiplication)
/ (division)

int product = 4 * 2; // 8 The full Arduino code reference can be found here:
int radius = 12 % 5; // 2 https://www.arduino.cc/reference
int area = 2 * 3.14 * radius; // 12.76
Components Power ratings

Board DC input: 6...20V (7-12V recommended)


Maximum DC current per I/O pin: 20mA
Maximum DC current on VCC, GND: 200mA

Basic output circuits

Left: LED
Right: 5V relay or small DC motor

Connectors

Basic input circuits

Left: button or switch


Center: potmeter
Right: Light or temperature dependent resistor

ATmega328 specifications (Uno, Duemilanove)

Processor: 8-bit AVR


Clock: 16 MHz
Flash memory: 32 kB
SRAM: 2 kB
EEPROM: 1kB
Digital I/O pins: 14 (of which 6 PWM capable)
Servo leads
Analog inputs: 6
Interrupts: 2
Black or brown = GND
Protocols: Serial, I2C/TWI, SPI, PWM
Red = +5V
Size: 68.6 x 53.4 mm
White or orange = PWM
Weight: 25 g

This document is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
Check my website for the latest version of this document: http://www.pa3hcm.nl/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy