38#define adcResolution 12
45#define SerialPort ConnectorUsb
52 SerialPort.Mode(Connector::USB_CDC);
53 SerialPort.Speed(baudRate);
54 uint32_t timeout = 5000;
56 SerialPort.PortOpen();
57 while (!SerialPort &&
Milliseconds() - startTime < timeout) {
62 ConnectorIO0.
Mode(Connector::OUTPUT_DIGITAL);
63 ConnectorIO1.
Mode(Connector::OUTPUT_DIGITAL);
64 ConnectorIO2.
Mode(Connector::OUTPUT_DIGITAL);
65 ConnectorIO3.
Mode(Connector::OUTPUT_DIGITAL);
66 ConnectorIO4.
Mode(Connector::OUTPUT_DIGITAL);
67 ConnectorIO5.
Mode(Connector::OUTPUT_DIGITAL);
70 ConnectorIO0.
State(
false);
71 ConnectorIO1.
State(
false);
72 ConnectorIO2.
State(
false);
73 ConnectorIO3.
State(
false);
74 ConnectorIO4.
State(
false);
75 ConnectorIO5.
State(
false);
86 int16_t adcResult = ConnectorA12.
State();
88 double inputVoltage = 10.0 * adcResult / ((1 << adcResolution) - 1);
91 SerialPort.Send(
"A-12 input voltage: ");
92 SerialPort.Send(inputVoltage);
93 SerialPort.SendLine(
"V.");
97 if (inputVoltage > 0.1) {
98 ConnectorIO0.
State(
true);
101 ConnectorIO0.
State(
false);
103 if (inputVoltage > 2.0) {
104 ConnectorIO1.
State(
true);
107 ConnectorIO1.
State(
false);
109 if (inputVoltage > 4.0) {
110 ConnectorIO2.
State(
true);
113 ConnectorIO2.
State(
false);
115 if (inputVoltage > 6.0) {
116 ConnectorIO3.
State(
true);
119 ConnectorIO3.
State(
false);
121 if (inputVoltage > 8.0) {
122 ConnectorIO4.
State(
true);
125 ConnectorIO4.
State(
false);
127 if (inputVoltage >= 9.9) {
128 ConnectorIO5.
State(
true);
131 ConnectorIO5.
State(
false);
void Delay_ms(uint32_t ms)
Blocks operations for ms milliseconds.
Definition SysTiming.h:287
uint32_t Milliseconds(void)
Number of milliseconds since the ClearCore was initialized.
bool AdcResolution(uint8_t resolution)
Configure the ADC conversion resolution.
int16_t State() override
Get the connector's last majority-filtered sampled value.
int16_t State() override
Get connector's last sampled digital value.
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition DigitalInOutAnalogOut.h:70
int16_t State() override
Get connector's last sampled value.
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition DigitalInOutHBridge.h:124
virtual ConnectorModes Mode() override
Get the connector's operational mode.
Definition DigitalInOut.h:85
int16_t State() override
Get the connector's last majority-filtered sampled value.