Complete reference for Arduino programming language, functions, and libraries.
pinMode(), digitalRead(), digitalWrite()
analogRead(), analogWrite(), analogReference()
millis(), micros(), delay(), delayMicroseconds()
Serial.begin(), Serial.print(), Serial.read()
shiftOut(), pulseIn(), tone(), noTone()
WiFi library, ESP8266, ESP32 functions
Wire library, SPI communication protocols
Built-in and contributed libraries
Configures the specified pin to behave either as an input or an output.
pinMode(pin, mode)
pin: the Arduino pin numbermode: INPUT, OUTPUT, or INPUT_PULLUPvoid setup() {
pinMode(LED_BUILTIN, OUTPUT); // sets the digital pin 13 as output
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turns the LED on
delay(1000); // waits for 1 second
digitalWrite(LED_BUILTIN, LOW); // turns the LED off
delay(1000); // waits for 1 second
}
Write a HIGH or LOW value to a digital pin.
digitalWrite(pin, value)
pin: the Arduino pin numbervalue: HIGH or LOWint ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop() {
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
Reads the value from the specified analog pin. Arduino boards contain a multichannel, 10-bit analog to digital converter.
analogRead(pin)
pin: the analog input pin numberint analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup() {
Serial.begin(9600); // setup serial
}
void loop() {
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}