According to this manuel from RAK, there is a list of digital I/O available to use with digitalRead
and digitalWrite
. How about analog I/O (PWM)? I can only find the two analog input available. Is analogWrite
available on RAK3172? And if that is the case, any information on the maximum frequency and resolution? I think the online documentation is missing this important information.
1 Like
I didn’t try it and I do not know the frequency, but analogWrite
is supported:
/**@par Description
* Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(),
* the pin will generate a steady rectangular wave of the specified duty cycle until the next call to analogWrite()
* @par Syntax
* analogWrite(pin, value)
* @param pin the pin which you want to read
* @param value the duty cycle: between 0 (always off) and 255 (always on)
*
* @return void
* @par Example
* @verbatim
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
}
@endverbatim
*/
void analogWrite(uint8_t pin, int value);
For analogRead
, at the moment only PB3 and PB4 are supported as analog inputs in RUI3.