0% found this document useful (0 votes)
7 views4 pages

Ard Functions-1

The document outlines various functions used in embedded systems, categorized into timer functions, communication functions, interrupt functions, and math functions. Each category includes specific functions with their purpose, syntax, and parameters. Examples include setTimer() for setting timers, Serial.begin() for initializing serial communication, attachInterrupt() for managing interrupts, and mathematical functions like abs() and sqrt().
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Ard Functions-1

The document outlines various functions used in embedded systems, categorized into timer functions, communication functions, interrupt functions, and math functions. Each category includes specific functions with their purpose, syntax, and parameters. Examples include setTimer() for setting timers, Serial.begin() for initializing serial communication, attachInterrupt() for managing interrupts, and mathematical functions like abs() and sqrt().
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Timer Functions

Timer functions are used in embedded systems and programming environments to measure
time intervals or trigger actions after specific delays. Below are some commonly used timer
functions:

1. setTimer()

 Purpose: Sets a timer to trigger after a specified delay.

 Syntax: setTimer(timerID, delay)

 Parameters:

o timerID: Unique identifier for the timer.

o delay: Time delay in milliseconds or microseconds.

2. getTimer()

 Purpose: Returns the current value of the timer.

 Syntax: getTimer(timerID)

 Parameters:

o timerID: The unique timer identifier.

3. stopTimer()

 Purpose: Stops the specified timer.

 Syntax: stopTimer(timerID)

 Parameters:

o timerID: The unique timer identifier.

4. restartTimer()

 Purpose: Restarts a previously set timer.

 Syntax: restartTimer(timerID)

 Parameters:

o timerID: The unique timer identifier.

Communication Functions
These functions are essential for enabling communication between systems or devices, such
as UART, SPI, or I2C communication.

1. Serial.begin()

 Purpose: Initializes the serial communication.

 Syntax: Serial.begin(baudRate)

 Parameters:

o baudRate: The baud rate for the serial communication.

2. Serial.print()

 Purpose: Sends data over the serial port.

 Syntax: Serial.print(data)

 Parameters:

o data: The data to send.

3. Serial.read()

 Purpose: Reads incoming data from the serial port.

 Syntax: Serial.read()

 Returns: The next byte of incoming serial data.

4. I2C.write()

 Purpose: Sends data to an I2C device.

 Syntax: I2C.write(deviceAddress, data)

 Parameters:

o deviceAddress: The address of the I2C device.

o data: The data to be sent.

Interrupt Functions

Interrupts are used to respond immediately to certain events, halting the regular program
flow and executing a specific function.

1. attachInterrupt()

 Purpose: Attaches an interrupt handler to a pin.

 Syntax: attachInterrupt(pin, ISR, mode)


 Parameters:

o pin: The pin number.

o ISR: The interrupt service routine to be called.

o mode: Triggering mode (e.g., RISING, FALLING, CHANGE).

2. detachInterrupt()

 Purpose: Detaches the interrupt from a pin.

 Syntax: detachInterrupt(pin)

 Parameters:

o pin: The pin number.

3. interrupts()

 Purpose: Enables interrupts globally.

 Syntax: interrupts()

4. noInterrupts()

 Purpose: Disables interrupts globally.

 Syntax: noInterrupts()

Math Functions

Math functions are used for performing various mathematical operations, such as addition,
subtraction, trigonometry, etc.

1. abs()

 Purpose: Returns the absolute value of a number.

 Syntax: abs(x)

 Parameters:

o x: The number whose absolute value is to be returned.

2. sqrt()

 Purpose: Returns the square root of a number.

 Syntax: sqrt(x)

 Parameters:
o x: The number to find the square root of.

3. pow()

 Purpose: Returns the value of the first argument raised to the power of the second
argument.

 Syntax: pow(base, exponent)

 Parameters:

o base: The base number.

o exponent: The exponent.

4. sin(), cos(), tan()

 Purpose: Trigonometric functions that return the sine, cosine, and tangent of an
angle, respectively.

 Syntax: sin(angle), cos(angle), tan(angle)

 Parameters:

o angle: The angle in radians.

You might also like