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

Commit b8a6e1c

Browse files
Updated Processing Function and Fixed Bug in ProcessingArray Function
1 parent 31ed297 commit b8a6e1c

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

arduino_controller/arduino_controller_functions.ino

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@ void ProcessData()
1111
{
1212

1313
PopulateArray();
14+
15+
// initialize all motors and get them moving
16+
for (int i = 0; i < NUMBER_MOTORS; i++)
17+
{
18+
if (motor_commands[i][1] == 0)
19+
{
20+
my_servo[i].write(100);
21+
}
22+
else if (motor_commands[i][1] == 1)
23+
{
24+
my_servo[i].write(80);
25+
}
26+
else if (motor_commands[i][1] == 2)
27+
{
28+
my_servo[i].write(90);
29+
}
30+
else if (motor_commands[i][1] == 3)
31+
{
32+
// call reset function (still needs to be written)
33+
}
34+
else
35+
{
36+
// Sends Error Message
37+
Invalid();
38+
}
39+
}
40+
41+
42+
1443
//
1544
/*
1645
// Print First Number
@@ -72,28 +101,27 @@ void PopulateArray()
72101

73102
if (value1 == "Up")
74103
{
75-
motor_commands[i][1] = 0;
104+
motor_commands[i][0] = 0;
76105
}
77106
else if (value1 == "Down")
78107
{
79-
motor_commands[i][1] = 1;
108+
motor_commands[i][0] = 1;
80109
}
81-
82110
else if (value1 == "None")
83111
{
84-
motor_commands[i][1] = 2;
112+
motor_commands[i][0] = 2;
85113
}
86114
else if (value1 == "Reset")
87115
{
88-
motor_commands[i][1] = 3;
116+
motor_commands[i][0] = 3;
89117
}
90118
else
91119
{
92120
// Sends Error Message
93121
Invalid();
94122
}
95123

96-
motor_commands[i][2] = value2.toInt();
124+
motor_commands[i][1] = value2.toInt();
97125
}
98126

99127
// print array
@@ -102,9 +130,9 @@ void PopulateArray()
102130
Serial.print("Motor Number: ");
103131
Serial.print(i);
104132
Serial.print(" - ");
105-
Serial.print(motor_commands[i][1]);
133+
Serial.print(motor_commands[i][0]);
106134
Serial.print(" - ");
107-
Serial.println(motor_commands[i][2]);
135+
Serial.println(motor_commands[i][1]);
108136
}
109137
}
110138

0 commit comments

Comments
 (0)