Skip to main content

Analog I/O

Analog I/O

This library is to input/output an analog signal.

analogReference

Description
Configures the reference voltage used for analog input (i.e. the value used as the top of the input range).
Syntax
analogReference(uint8_t mode)
Parameters
mode:
DEFAULT: 3.3V
INTERNAL: 1.1V (internal voltage)
EXTERNAL: AVREF pin supply voltage
Returns
None

analogRead

Description
Reads the value from the specified analog pin.
Syntax
int analogRead(uint8_t analog_pin)
Parameters
analog_pin: The number of the analog input pin to read from A0(14) to A5(19) and A6(10) to A9(13)
Returns
0 to 4095

analogWrite

Description
Writes an analog value (PWM wave) to a pin. Can be used to light an LED at varying brightnesses or drive a motor at various speeds. The frequency of the PWM signal is approximately 490Hz.
Syntax
analogWrite(uint8_t pin, int value);
Parameters
pin: The number of the pin
value: The duty cycle of the output PWM (0 - 255).
Returns
None

analogWriteDAC

Description
Outputs digital values which it first converts to analog. Unlike analogWrite, it does not output a PWM signal. 3.3V are output when the digital value is 4095.
Syntax
analogWriteDAC(int pin, int value)
Parameters
pin: The number of the pin to write to (24 only)
value: Analog converted value (0 - 4095).
Returns
None

analogWriteFrequency

Description
Change the frequency of PWM from the default of 490Hz. The pins 3, 7, 9, 10, and 13 can be changed.
Syntax
analogWriteFrequency(uint32_t freq);
Parameters
freq: Frequency
Returns
None

Sample Program

The LED on the GR-ROSE board lights up smoothly.


#include <Arduino.h>
void setup(){
}
  
void loop(){
    for(int i = 0; i < 256; i++){
        analogWrite(PIN_LED1, i);
        delay(3);
    }
    for(int i = 0; i < 256; i++){
        analogWrite(PIN_LED1, 256 - i - 1);
        delay(3);
    }
}

Support

Support Communities

Support Communities

Get quick technical support online from Renesas Engineering Community technical staff.
Browse Articles

Knowledge Base

Browse our knowledge base for helpful articles, FAQs, and other useful resources.
Submit a Ticket

Submit a Ticket

Need to ask a technical question or share confidential information?