Create a class ADCChannel that represents an analog-to-digital converter (ADC) configuration on a microcontroller. The object must validate inputs inside the constructor, ensuring the channel and resolution are always safe and legal.
Details you must implement:
int channelint resolutionADCChannel(int ch, int res)ch < 0, set channel = 0ch > 15, set channel = 15resolution = 12 (safe default)void print()CH=<channel> RES=<resolution>Program behavior (main()):
ch and resADCChannel object
Example 1
Input:
3 10Output:
CH=3 RES=10
Example 2
Input (invalid channel and invalid resolution):
20 9Example Output:
CH=15 RES=12 Explanation:
20 → clamped to 159 → not in {8,10,12} → default = 12
Constraints:
12 when invalid.
Input
3 10
Expected Output
CH=3 RES=10