Return to SDK Examples for Microchip Studio
#include "ClearCore.h"
#define adcResolution 12
#define baudRate 9600
#define SerialPort ConnectorUsb
int main() {
SerialPort.Mode(Connector::USB_CDC);
SerialPort.Speed(baudRate);
uint32_t timeout = 5000;
SerialPort.PortOpen();
while (!SerialPort &&
Milliseconds() - startTime < timeout) {
continue;
}
while (true) {
double inputVoltage = 10.0 * adcResult / ((1 << adcResolution) - 1);
SerialPort.Send("A-12 input voltage: ");
SerialPort.Send(inputVoltage);
SerialPort.SendLine("V.");
if (inputVoltage > 0.1) {
}
else {
}
if (inputVoltage > 2.0) {
}
else {
}
if (inputVoltage > 4.0) {
}
else {
}
if (inputVoltage > 6.0) {
}
else {
}
if (inputVoltage > 8.0) {
}
else {
}
if (inputVoltage >= 9.9) {
}
else {
}
}
}