-
Notifications
You must be signed in to change notification settings - Fork 0
/
SEG.h
137 lines (109 loc) · 3.07 KB
/
SEG.h
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
class SEG {
public:
RUN(char *part,int num) {
// SEG 1
pinMode(9, OUTPUT);
// SEG 2
pinMode(10, OUTPUT);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
int A = 0, B = 1, C = 2, D = 3, E = 4, F = 5,G = 6;
int PIN_OUT[] = {A = 0, B = 1, C = 2, D = 3, E = 4, F = 5,G = 6};
// A B C D E F G
int _0[] = {1,1,1,1,1,1,0};
int _1[] = {0,1,1,0,0,0,0};
int _2[] = {1,1,0,1,1,0,1};
int _3[] = {1,1,1,1,0,0,1};
int _4[] = {0,1,1,0,0,1,1};
int _5[] = {1,0,1,1,0,1,1};
int _6[] = {1,0,1,1,1,1,1};
int _7[] = {1, 1, 1, 0, 0, 0, 0};
int _8[] = {1, 1, 1, 1, 1, 1, 1};
int _9[] = {1,1,1,1,0,1,1};
byte _set[] = {"B0000001"};
////////////////////////////////////////
if(part=="1"){
digitalWrite(10,LOW);
delay(7);
}
else if(digitalRead(9)==LOW){
digitalWrite(10,HIGH);
}
if(part=="2"){
digitalWrite(9,LOW);
delay(7);
}
else if(digitalRead(10)==LOW){
digitalWrite(9,HIGH);
}
if (num == 0) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _0[x]);
}
}
if (num == 1) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _1[x]);
}
}
if (num == 2) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _2[x]);
}
}
if (num == 3) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _3[x]);
}
}
if (num == 4) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _4[x]);
}
}
if (num == 5) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _5[x]);
}
}
if (num == 6) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _6[x]);
}
}
if (num == 7) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _7[x]);
}
}
if (num == 8) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _8[x]);
}
}
if (num == 9) {
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _9[x]);
}
}
/* else{
for (int x = 0; x < 7; x++) {
pinMode(PIN_OUT[x], OUTPUT);
digitalWrite(PIN_OUT[x], _set[x]);
delay(100);
digitalWrite(PIN_OUT[x],LOW);
delay(100);
}
}*/
}
};