This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 6
6
#define SAMPLE_FREQUENCY 20
7
7
#define MAXIMUM (DEBOUNCE_TIME * SAMPLE_FREQUENCY)
8
8
#define NUMBER_MOTORS 1
9
+ #define TIMEOUT 10000
9
10
10
11
// relay pin
11
12
int relayPin = 53 ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ void ProcessData()
13
13
bool is_reset = false ;
14
14
bool go = true ;
15
15
int total_turns = 0 ;
16
+ long timeout_counter = 0
16
17
17
18
PopulateArray ();
18
19
@@ -103,14 +104,22 @@ void ProcessData()
103
104
go = false ;
104
105
}
105
106
total_turns = 0 ;
107
+
108
+ // time out loop if stall
109
+ if (timeout_counter >= TIMEOUT)
110
+ {
111
+ go = false ;
112
+ }
113
+ timeout_counter = timeout_counter + 1
114
+
115
+
106
116
}
107
117
}
108
118
else
109
119
{
110
120
int reset_counter[NUMBER_MOTORS] = {1 }
111
121
while (go == true )
112
122
{
113
-
114
123
// stop motors that have reached 0
115
124
for (int i = 0 ; i < NUMBER_MOTORS; i++)
116
125
{
@@ -128,10 +137,16 @@ void ProcessData()
128
137
// Serial.print("Total number of turns in array: ");
129
138
// Serial.println(total_turns);
130
139
}
140
+
131
141
if (total_turns <= 0 )
142
+ {
143
+ go = false ;
144
+ }
145
+ if (timeout_counter >= TIMEOUT)
132
146
{
133
147
go = false ;
134
148
}
149
+ timeout_counter = timeout_counter + 1
135
150
}
136
151
}
137
152
// Send Finished Signal
You can’t perform that action at this time.
0 commit comments