Introduction
Arduino programming is one of the easiest ways for students and beginners to start learning electronics and embedded systems.
This Arduino commands list includes the 50 most important Arduino functions used in programming, electronics projects, and sensor applications. This list works as a quick reference and cheat sheet for students learning Arduino programming.
| # | Command | Description |
|---|---|---|
| 1 | pinMode() | Configure pin as INPUT or OUTPUT |
| 2 | digitalWrite() | Set digital pin HIGH or LOW |
| 3 | digitalRead() | Read digital pin state |
| 4 | analogWrite() | Write PWM value to pin |
| 5 | analogRead() | Read analog sensor value |
| 6 | delay() | Pause program execution |
| 7 | millis() | Time since program started |
| 8 | micros() | Time in microseconds |
| 9 | Serial.begin() | Start serial communication |
| 10 | Serial.print() | Print data to serial monitor |
| 11 | Serial.println() | Print line to serial monitor |
| 12 | Serial.read() | Read serial data |
| 13 | Serial.available() | Check serial buffer |
| 14 | random() | Generate random numbers |
| 15 | map() | Convert value ranges |
| 16 | constrain() | Limit value within range |
| 17 | abs() | Absolute value |
| 18 | sq() | Square a number |
| 19 | sqrt() | Square root |
| 20 | pow() | Power calculation |
| 21 | sin() | Sine function |
| 22 | cos() | Cosine function |
| 23 | tan() | Tangent function |
| 24 | HIGH | Digital HIGH constant |
| 25 | LOW | Digital LOW constant |
| 26 | INPUT | Pin input mode |
| 27 | OUTPUT | Pin output mode |
| 28 | INPUT_PULLUP | Enable internal pull-up resistor |
| 29 | attachInterrupt() | Attach interrupt |
| 30 | detachInterrupt() | Detach interrupt |
| 31 | noTone() | Stop tone generation |
| 32 | tone() | Generate tone |
| 33 | tone(pin,freq,duration) | Tone with duration |
| 34 | shiftOut() | Send serial data |
| 35 | shiftIn() | Receive serial data |
| 36 | bitRead() | Read bit value |
| 37 | bitWrite() | Write bit value |
| 38 | bitSet() | Set bit to 1 |
| 39 | bitClear() | Set bit to 0 |
| 40 | word() | Create 16-bit number |
| 41 | lowByte() | Get lower byte |
| 42 | highByte() | Get higher byte |
| 43 | isAlpha() | Check if letter |
| 44 | isDigit() | Check if number |
| 45 | delayMicroseconds() | Delay in microseconds |
| 46 | detach() | Detach servo |
| 47 | EEPROM.write() | Write EEPROM value |
| 48 | EEPROM.read() | Read EEPROM value |
| 49 | pulseIn() | Measure pulse duration |
| 50 | interrupts() | Enable interrupts |
Table of Contents
- Basic Pin Control Commands
- Timing Functions
- Serial Communication
- Math Functions
- Digital Logic Constants
- Interrupt Functions
- Sound Functions
- Bit Manipulation
- Data Handling
- Character Functions
- Timing in Microseconds
- EEPROM Memory
- Pulse Measurement
- Interrupt Control
1️⃣ Basic Pin Control Commands
1. pinMode(pin, mode)
Configures a pin as an input or output.
Example:
pinMode(13, OUTPUT);
2. digitalWrite(pin, value)
Turns a digital pin ON or OFF.
digitalWrite(13, HIGH);
3. digitalRead(pin)
Reads the state of a digital pin.
int state = digitalRead(2);
4. analogWrite(pin, value)
Writes a PWM value (0–255).
analogWrite(9, 128);
5. analogRead(pin)
Reads an analog value (0–1023).
int sensor = analogRead(A0);
2️⃣ Timing Functions
6. delay(ms)
Pauses the program for milliseconds.
delay(1000);
7. millis()
Returns the number of milliseconds since the program started.
long time = millis();
8. micros()
Returns the time in microseconds.
long time = micros();
3️⃣ Serial Communication
9. Serial.begin(speed)
Initializes serial communication.
Serial.begin(9600);
10. Serial.print(value)
Prints data to the serial monitor.
Serial.print("Hello World");
11. Serial.println(value)
Prints with a new line.
Serial.println(123);
12. Serial.read()
Reads data from the serial port.
char data = Serial.read();
13. Serial.available()
Returns available bytes in the serial buffer.
if (Serial.available() > 0) { }
4️⃣ Math Functions
14. random(min,max)
Generates a random number.
int num = random(1,100);
15. map(value,inMin,inMax,outMin,outMax)
Maps a value from one range to another.
int newValue = map(sensor,0,1023,0,255);
16. constrain(value,min,max)
Limits a value to a range.
value = constrain(value,10,100);
17. abs(value)
Returns absolute value.
int a = abs(-5);
18. sq(value)
Returns square of a number.
int x = sq(4);
19. sqrt(value)
Returns square root.
float r = sqrt(25.0);
20. pow(base,exponent)
Calculates power.
float result = pow(2,3);
21. sin(angle)
Calculates sine.
float s = sin(PI/2);
22. cos(angle)
Calculates cosine.
float c = cos(PI);
23. tan(angle)
Calculates tangent.
float t = tan(PI/4);
5️⃣ Digital Logic Constants
24. HIGH
Represents logical HIGH.
digitalWrite(13,HIGH);
25. LOW
Represents logical LOW.
digitalWrite(13,LOW);
26. INPUT
Defines pin as input.
27. OUTPUT
Defines pin as output.
28. INPUT_PULLUP
Activates internal pull-up resistor.
6️⃣ Interrupt Functions
29. attachInterrupt()
Attaches an interrupt to a pin.
attachInterrupt(digitalPinToInterrupt(2), myFunction, RISING);
30. detachInterrupt()
Disables interrupt.
7️⃣ Sound Functions
31. noTone(pin)
Stops tone generation.
32. tone(pin,frequency)
Generates a square wave.
33. tone(pin,frequency,duration)
Tone with duration.
8️⃣ Bit Manipulation
36. bitRead(value,bit)
Reads a bit.
37. bitWrite(value,bit,state)
Writes a bit.
38. bitSet(value,bit)
Sets bit to 1.
39. bitClear(value,bit)
Clears bit.
9️⃣ Data Handling
40. word(value)
Converts number to 16-bit word.
41. lowByte(value)
Gets low byte.
42. highByte(value)
Gets high byte.
🔟 Character Functions
43. isAlpha(character)
Checks if character is a letter.
44. isDigit(character)
Checks if character is a number.
11️⃣ Microsecond Timing
45. delayMicroseconds(us)
Pauses program in microseconds.
12️⃣ Memory Functions
47. EEPROM.write(address,value)
Writes value to EEPROM.
48. EEPROM.read(address)
Reads value from EEPROM.
13️⃣ Pulse Measurement
49. pulseIn(pin,state)
Measures pulse duration.
14️⃣ Interrupt Control
50. interrupts()
Enables interrupts.
Conclusion
Learning these 50 Arduino commands and functions will help students understand how Arduino programs interact with hardware, sensors, and electronic devices.
This list works as a quick reference for beginners and a useful cheat sheet for Arduino programming.
Related Arduino Tutorials
- Blinking LED with Arduino
- Arduino LED with Push Button
- Arduino Traffic Light Project
- Ultrasonic Sensor HC-SR04 Project
