16. ADC
The adc object is a built-in object that provides ADC functionality.
adc Global Object
Methods()/Properties | Summary | Version | Note |
---|---|---|---|
adc.read() | Gets the analog-to-digital conversion value. | 00.00.16+ |
Details
adc.read(adcNo)
Gets the analog-to-digital conversion value.
Name | Type | M/O | Summary | Note |
---|---|---|---|---|
adcNo | number | mandatory | ADC number Please refer to Pinout for ADC number. | |
return | number, null | - | number : Read value (0 - 4095) null : Read failure | In the case of parameter error, an exception occurs. |
Object Usage Examples
Sample1
This is a sample to read the analog value.
Reads and displays the values of ADC1 and ADC2 at 2-second intervals.
setInterval(function() {
print('ADC1:' + adc.read(1));
print('ADC2:' + adc.read(2));
}, 2000);
Updated: 2020-05-01