RTduino Source Code Reference Manual
|
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... | |
Analog input and output functions.
int analogRead | ( | uint8_t | pin | ) |
Reads the analog input on a specified analog pin.
/
pin | The number of the analog input pin. |
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.
pin | The pin number. |
void analogReadResolution | ( | uint8_t | bits | ) |
Sets the number of bits of resolution for the analogRead function.
/
bits | The number of bits (e.g., 8, 10, 12) for the resolution. |
Sets the number of bits of resolution for the analogRead function.
bits | The resolution in bits. |
void analogReference | ( | uint8_t | mode | ) |
Configures the reference voltage used for analog input (e.g., external, internal, etc.).
/
mode | The type of reference (e.g., DEFAULT, INTERNAL, EXTERNAL). |
Configures the reference voltage used for analog input (e.g., external, internal, etc.).
This function is not yet implemented.
mode | The reference voltage mode. |
void analogWrite | ( | uint8_t | pin, |
int | val | ||
) |
Writes an analog value (PWM wave) to a pin.
/
pin | The number of the PWM pin. |
val | The duty cycle: between 0 (always off) and 255 (always on). |
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.
pin | The pin number. |
val | The analog value to write. |
void analogWriteFrequency | ( | uint32_t | frequency | ) |
Sets the frequency of the PWM on a pin.
/
frequency | The desired frequency in Hertz (cycles per second). |
Sets the frequency of the PWM on a pin.
frequency | The frequency in Hz. |
void analogWriteResolution | ( | uint8_t | bits | ) |
Sets the number of bits of resolution for the analogWrite function.
/
bits | The number of bits (e.g., 8, 10, 12) for the resolution. |
Sets the number of bits of resolution for the analogWrite function.
bits | The resolution in bits. |