/
SetValueExample.ino
74 lines (54 loc) · 1.25 KB
/
SetValueExample.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <DigitShield.h>
void setup() {
DigitShield.begin();
}
void loop() {
int d = 500;
// display "123"
DigitShield.setValue(123);
delay(d);
// display "123.0"
DigitShield.setPrecision(1);
delay(d);
// attempt to display "123.00"
// this is invalid and the 4 decimal points will be on.
DigitShield.setPrecision(2);
delay(d);
// displays "123" again
DigitShield.setPrecision(0);
delay(d);
// display "0"
DigitShield.setValue(0);
delay(d);
// display "0.0"
DigitShield.setPrecision(1);
delay(d);
// display "0.00"
DigitShield.setPrecision(2);
delay(d);
// display "043.0"
DigitShield.setPrecision(1);
DigitShield.setValue(43);
DigitShield.setLeadingZeros(true);
delay(d);
// display "0.001"
DigitShield.setLeadingZeros(false);
DigitShield.setPrecision(3);
DigitShield.setValue(.001);
delay(d);
// display "3.14"
DigitShield.setPrecision(2);
DigitShield.setValue(3.14159);
delay(d);
// display "3.142"
DigitShield.setPrecision(3);
delay(d);
// display "3"
DigitShield.setPrecision(0);
delay(d);
// attemp to display negative number
// this is invalid and the 4 decimal points will be on.
DigitShield.setValue(-32);
DigitShield.setPrecision(0);
delay(d);
}