Skip to content

Commit 2f58454

Browse files
committed
Modify WriteAnalogCurrentOutput example comments and loop structure to be consistent with Atmel example. Add note about using 4-20 mA operating range.
1 parent e689576 commit 2f58454

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

libraries/AnalogIO/WriteAnalogCurrentOutput/WriteAnalogCurrentOutput.ino

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,20 @@ void setup() {
3636
void loop() {
3737
// Put your main code here, it will run repeatedly:
3838

39-
// Ramp the current output of IO-0 up to 20mA.
39+
// Ramp the current output of IO-0 up to 20 mA. If using an operating
40+
// range of 4-20 mA, change the lower bounds of the loops below to 410
41+
// instead of 0.
4042
for (uint16_t value = 0; value < 2047; value++) {
4143
// ClearCore's analog current output has 11-bit resolution, so we write
42-
// values of 0 to 2047 (corresponding to 0-20mA).
44+
// values of 0 to 2047 (corresponding to 0-20 mA) or 410 to 2047
45+
// (corresponding to 4-20 mA).
4346
analogWrite(IO0, value, CURRENT);
4447
delay(2);
4548
}
4649

4750
// Ramp the current output of IO-0 back down.
48-
for (uint16_t value = 0; value < 2047; value++) {
49-
analogWrite(IO0, 2047 - value, CURRENT);
51+
for (uint16_t value = 2047; value > 0; value--) {
52+
analogWrite(IO0, value, CURRENT);
5053
delay(2);
5154
}
5255
}

0 commit comments

Comments
 (0)