![]() |
RUI3 (RAK Unified Interface 3) - RAK4631
|
Functions | |
int | analogRead (uint8_t pin) |
void | analogReference (eAnalogReference mode) |
void | analogOversampling (uint32_t ulOversampling) |
void | analogWrite (uint8_t pin, int value) |
void | analogReadResolution (uint8_t bits) |
void | analogWriteResolution (uint8_t bits) |
int analogRead | ( | uint8_t | pin | ) |
pin | the name of the analog input pin to read from |
void analogReference | ( | eAnalogReference | mode | ) |
type | which type of reference to use Type List: RAK_ADC_MODE_DEFAULT RAK_ADC_MODE_3_0 RAK_ADC_MODE_2_4 RAK_ADC_MODE_1_8 RAK_ADC_MODE_1_2 |
void analogOversampling | ( | uint32_t | ulOversampling | ) |
void analogWrite | ( | uint8_t | pin, |
int | value | ||
) |
pin | the pin which you want to read |
value | the duty cycle: between 0 (always off) and 255 (always on) |
int val = 0; // variable to write the LED pin bool state = false; bool ledSwitch = false; void valChage() { state = !state; if(val == 0) ledSwitch = !ledSwitch; } void setup() { // put your setup code here, to run once: pinMode(GREEN_LED, OUTPUT); pinMode(BLUE_LED, OUTPUT); } void loop() { // put your main code here, to run repeatedly: if(val == 0 || val == 255) valChage(); // To determine to make the led lighter or darker if(state) val++; else val--; // To switch the lighting led if(ledSwitch) analogWrite(GREEN_LED ,val); // Light the green led else analogWrite(BLUE_LED, val); //Light the blue led }
void analogReadResolution | ( | uint8_t | bits | ) |
Sets the size (in bits) of the value returned by analogRead(). It defaults to 10 bits (returns values between 0-1023) for backward compatibility with AVR based boards.
bits | determines the resolution (in bits) of the value returned by the analogRead() function. You can set this between 1 and 32. You can set resolutions higher than the supported 12 or 16 bits, but values returned by analogRead() will suffer approximation |
void analogWriteResolution | ( | uint8_t | bits | ) |
bits | determines the resolution (in bits) of the values used in the analogWrite() function. The value can range from 1 to 32. If you choose a resolution higher or lower than your board’s hardware capabilities, the value used in analogWrite() will be either truncated if it’s too high or padded with zeros if it’s too low |