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

Arduino Built in Functions

The document outlines various built-in functions available in Arduino, categorized into Basic Input/Output, Time, Serial Communication, Math, Trigonometric, Random and Bitwise, and Other Utility Functions. Each category includes specific functions with brief descriptions of their purpose and usage. These functions enable users to control hardware, manage time, perform calculations, and handle data communication effectively.

Uploaded by

Shahzaib Shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Arduino Built in Functions

The document outlines various built-in functions available in Arduino, categorized into Basic Input/Output, Time, Serial Communication, Math, Trigonometric, Random and Bitwise, and Other Utility Functions. Each category includes specific functions with brief descriptions of their purpose and usage. These functions enable users to control hardware, manage time, perform calculations, and handle data communication effectively.

Uploaded by

Shahzaib Shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Arduino Built-in Functions

1. Basic Input/Output Functions


• pinMode(pin, mode) – Configures a pin as INPUT, OUTPUT, or INPUT_PULLUP.

• digitalWrite(pin, value) – Sets a digital pin HIGH or LOW.

• digitalRead(pin) – Reads the state of a digital pin (HIGH or LOW).

• analogWrite(pin, value) – Outputs a PWM signal (0-255) on a PWM-enabled pin.

• analogRead(pin) – Reads an analog value (0-1023) from an analog pin.

2. Time Functions
• delay(ms) – Pauses the program for a specified number of milliseconds.

• delayMicroseconds(us) – Pauses for a specified number of microseconds.

• millis() – Returns the number of milliseconds since the Arduino started.

• micros() – Returns the number of microseconds since the Arduino started.

3. Serial Communication Functions


• Serial.begin(baud_rate) – Initializes serial communication at the given baud rate.

• Serial.print(data) – Sends data to the serial monitor as text.

• Serial.println(data) – Sends data to the serial monitor followed by a newline.

• Serial.read() – Reads incoming serial data.

• Serial.available() – Returns the number of bytes available to read.

4. Math Functions
• abs(x) – Returns the absolute value of x.

• constrain(x, min, max) – Limits a value between min and max.

• map(x, fromLow, fromHigh, toLow, toHigh) – Maps a number from one range to another.

• max(x, y) – Returns the larger of two values.

• min(x, y) – Returns the smaller of two values.

• pow(base, exponent) – Calculates the power of a number.

• sqrt(x) – Returns the square root of x.


5. Trigonometric Functions
• sin(angle) – Returns the sine of an angle (in radians).

• cos(angle) – Returns the cosine of an angle.

• tan(angle) – Returns the tangent of an angle.

6. Random and Bitwise Functions


• random(max) – Generates a random number between 0 and max-1.

• random(min, max) – Generates a random number between min and max-1.

• randomSeed(seed) – Sets the seed for the random number generator.

• bitRead(value, bit) – Reads a specific bit from a number.

• bitWrite(value, bit, newValue) – Writes a specific bit in a number.

• bitSet(value, bit) – Sets a specific bit to 1.

• bitClear(value, bit) – Clears a specific bit (sets to 0).

7. Other Utility Functions


• highByte(value) – Returns the high byte of a 16-bit number.

• lowByte(value) – Returns the low byte of a 16-bit number.

• shiftLeft(value, bit) – Shifts a value left by a number of bits.

• shiftRight(value, bit) – Shifts a value right by a number of bits.

You might also like