Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit d9efe8c

Browse files
Fixed reset bug and added new port mappings
1 parent 15397df commit d9efe8c

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
3+
4+
{{11, 12, 13}, {8, 9, 10}, {5, 6, 7}, {2, 3, 4}, {14, 15, 16}, {17, 18, 19}, {20, 21, 22}, {23, 24, 25}, {29, 30, 31}, {35, 36, 37}, {41, 42, 43}, {47, 48, 49}, {26, 27, 28}, {32, 33, 34}, {38, 39, 40}, {44, 45, 46}, {50, 51, 52}, {53, 54, 55}, {56, 57, 58}, {59, 60, 61}, {63, 64, 65}, {62, 66, 67}};

arduino_controller/arduino_controller.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
#define DEBOUNCE_TIME .4
66
#define SAMPLE_FREQUENCY 20
77
#define MAXIMUM (DEBOUNCE_TIME * SAMPLE_FREQUENCY)
8-
#define NUMBER_MOTORS 1
8+
#define NUMBER_MOTORS 3
99
#define TIMEOUT 10000
1010

1111
// relay pin
12+
//int relayPin = 69;
1213
int relayPin = 53;
1314

1415
// function declarations`
@@ -25,18 +26,17 @@ bool new_data = false;
2526
// initialize motors
2627
Servo my_servo[NUMBER_MOTORS];
2728
// create a array of ports with the order: motor, counter, reset
28-
int ports[NUMBER_MOTORS][3] = {{2, 3, 4}};
29-
// int ports[NUMBER_MOTORS][3] = {{2, 3, 4}, {5, 6, 7}, {8, 9, 10}, {11, 12, 13}, {22, 23, 24}, {25, 26, 27}, {28, 29, 30}, {31, 32, 33}, {34, 35, 36}};
30-
// int ports[NUMBER_MOTORS][3] = {{2, 3, 4}, {5, 6, 7}, {8, 9, 10}, {11, 12, 13}, {22, 23, 24}, {25, 26, 27}};
29+
// int ports[NUMBER_MOTORS][3] = {{62, 66, 67}};
30+
int ports[NUMBER_MOTORS][3] = {{2, 3, 4},{5, 6, 7},{8, 9, 10}};
3131
// integer array that contains the direction and number of rotations a motor
3232
// needs to go
3333
int motor_commands[NUMBER_MOTORS][2] = {0};
3434

3535
// array of new switch values
36-
byte motor_sensor_counter1[NUMBER_MOTORS] = {1};
36+
byte motor_sensor_counter1[NUMBER_MOTORS] = {0};
3737

3838
// array of old switch values
39-
byte motor_sensor_counter2[NUMBER_MOTORS] = {1};
39+
byte motor_sensor_counter2[NUMBER_MOTORS] = {0};
4040

4141
// 0 or 1 depending on the input signal
4242
byte input[NUMBER_MOTORS] = {0};

arduino_controller/arduino_controller_functions.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ void ProcessData()
121121
}
122122
else
123123
{
124-
int reset_counter[NUMBER_MOTORS] = {1};
124+
int reset_counter[NUMBER_MOTORS] = {0};
125+
126+
for (int i = 0; i < NUMBER_MOTORS; ++i){
127+
reset_counter[i] = 1;
128+
}
125129

126130
while (go == true)
127131
{
@@ -140,6 +144,9 @@ void ProcessData()
140144
total_turns += reset_counter[i];
141145
}
142146

147+
Serial.print("Total Turns: ");
148+
Serial.println(total_turns);
149+
143150
if (total_turns <= 0)
144151
{
145152
go = false;

0 commit comments

Comments
 (0)