RTduino Source Code Reference Manual
Functions
I/O

Analog input and output functions. More...

Functions

int analogRead (uint8_t pin)
 Reads the analog input on a specified analog pin. More...
 
void analogWrite (uint8_t pin, int val)
 Writes an analog value (PWM wave) to a pin. More...
 
void analogReference (uint8_t mode)
 Configures the reference voltage used for analog input (e.g., external, internal, etc.). More...
 
void analogReadResolution (uint8_t bits)
 Sets the number of bits of resolution for the analogRead function. More...
 
void analogWriteResolution (uint8_t bits)
 Sets the number of bits of resolution for the analogWrite function. More...
 
void analogWriteFrequency (uint32_t frequency)
 Sets the frequency of the PWM on a pin. More...
 

Detailed Description

Analog input and output functions.

Function Documentation

◆ analogRead()

int analogRead ( uint8_t  pin)

Reads the analog input on a specified analog pin.

/

Parameters
pinThe number of the analog input pin.
Returns
The analog value read from the pin.
See also
https://www.arduino.cc/reference/en/language/functions/analog-io/analogread

Reads the analog input on a specified analog pin.

This function reads an analog value from the specified pin. If the pin supports ADC, the analog value is read from the pin. If the pin does not support ADC, an error message is logged and 0 is returned.

Parameters
pinThe pin number.
Returns
The analog value read from the pin. If the pin does not support ADC, 0 is returned.

◆ analogReadResolution()

void analogReadResolution ( uint8_t  bits)

Sets the number of bits of resolution for the analogRead function.

/

Parameters
bitsThe number of bits (e.g., 8, 10, 12) for the resolution.
See also
https://www.arduino.cc/reference/en/language/functions/analog-io/analogreadresolution

Sets the number of bits of resolution for the analogRead function.

Parameters
bitsThe resolution in bits.

◆ analogReference()

void analogReference ( uint8_t  mode)

Configures the reference voltage used for analog input (e.g., external, internal, etc.).

/

Parameters
modeThe type of reference (e.g., DEFAULT, INTERNAL, EXTERNAL).
See also
https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference

Configures the reference voltage used for analog input (e.g., external, internal, etc.).

This function is not yet implemented.

Parameters
modeThe reference voltage mode.

◆ analogWrite()

void analogWrite ( uint8_t  pin,
int  val 
)

Writes an analog value (PWM wave) to a pin.

/

Parameters
pinThe number of the PWM pin.
valThe duty cycle: between 0 (always off) and 255 (always on).
See also
https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite

Writes an analog value (PWM wave) to a pin.

This function writes an analog value to the specified pin. If the pin supports PWM, the analog value is converted to a PWM duty cycle and applied to the pin. If the pin supports DAC, the analog value is converted to a DAC value and applied to the pin. If the pin does not support PWM or DAC, the function falls back to digital write.

Parameters
pinThe pin number.
valThe analog value to write.

◆ analogWriteFrequency()

void analogWriteFrequency ( uint32_t  frequency)

Sets the frequency of the PWM on a pin.

/

Parameters
frequencyThe desired frequency in Hertz (cycles per second).
See also
https://www.arduino.cc/reference/en/language/functions/analog-io/analogwritefrequency

Sets the frequency of the PWM on a pin.

Parameters
frequencyThe frequency in Hz.

◆ analogWriteResolution()

void analogWriteResolution ( uint8_t  bits)

Sets the number of bits of resolution for the analogWrite function.

/

Parameters
bitsThe number of bits (e.g., 8, 10, 12) for the resolution.
See also
https://www.arduino.cc/reference/en/language/functions/analog-io/analogwriteresolution

Sets the number of bits of resolution for the analogWrite function.

Parameters
bitsThe resolution in bits.