Warning:

To protect the digital assets of creators and enhance system security and stability, the CyberBrick Multi-Function Core Board does not support firmware flashing with any third-party tools! If you need to restore the Multi-Function Core Board to its factory state, please wait for the official recovery tool to be released by CyberBrick. If you proceed to flash the firmware using third-party tools, the firmware of the Multi-Function Core Board will be permanently damaged and cannot be recovered. CyberBrick will not be responsible for any consequences resulting from such operations.

This documentation is adapted from the official MicroPython project. The CyberBrick team has extended the source code with custom interfaces and features to our hardware and application needs.

In addition to these enhancements, certain built-in MicroPython interfaces have been intentionally disabled to protect the system's integrity, and ensure the overall security and reliability of the device. This also facilitates content protection for creators' intellectual property, where applicable.

Portions of the content are derived from the official MicroPython documentation and have been included here under its open-source license to provide users with a consistent and enriched development experience tailored to the CyberBrick platform.

class ADCBlock – control ADC peripherals

The ADCBlock class provides access to an ADC peripheral which has a number of channels that can be used to sample analog values. It allows finer control over configuration of machine.ADC objects, which do the actual sampling.

This class is not always available.

Example usage:

from machine import ADCBlock

block = ADCBlock(id, bits=12)  # create an ADCBlock with 12-bit resolution
adc = block.connect(4, pin)    # connect channel 4 to the given pin
val = adc.read_uv()            # read an analog value

Constructors

class machine.ADCBlock(id, *, bits)

Access the ADC peripheral identified by id, which may be an integer or string.

The bits argument, if given, sets the resolution in bits of the conversion process. If not specified then the previous or default resolution is used.

Methods

ADCBlock.init(*, bits)

Configure the ADC peripheral. bits will set the resolution of the conversion process.

ADCBlock.connect(channel, *, ...)
ADCBlock.connect(source, *, ...)
ADCBlock.connect(channel, source, *, ...)

Connect up a channel on the ADC peripheral so it is ready for sampling, and return an ADC object that represents that connection.

The channel argument must be an integer, and source must be an object (for example a Pin) which can be connected up for sampling.

If only channel is given then it is configured for sampling.

If only source is given then that object is connected to a default channel ready for sampling.

If both channel and source are given then they are connected together and made ready for sampling.

Any additional keyword arguments are used to configure the returned ADC object, via its init method.