15. 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. | 01.03.00+ |
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 (-32767 - 32767) 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 ADC0 and ADC1 at 2-second intervals.
setInterval(function() {
print('ADC0:' + adc.read(0));
print('ADC1:' + adc.read(1));
}, 2000);
Updated: 2021-05-07