File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
libraries/AnalogIO/WriteAnalogCurrentOutput Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -36,17 +36,20 @@ void setup() {
3636void 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}
You can’t perform that action at this time.
0 commit comments