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

Commit 31ed297

Browse files
Added comments and formatted code
1 parent 18d4739 commit 31ed297

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

arduino_controller/arduino_controller.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Servo my_servo[NUMBER_MOTORS];
2323
// create a array of ports with the order: motor, counter, reset
2424
int ports[NUMBER_MOTORS][3] = {{2, 3, 4}, {5, 6, 7}};
2525

26-
// integer array that contains the direction and number of rotations a motor needs to go
26+
// integer array that contains the direction and number of rotations a motor
27+
// needs to go
2728
int motor_commands[NUMBER_MOTORS][2] = {0};
2829

2930
// array of new switch values

arduino_controller/arduino_controller_functions.ino

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
//////////////////////////////////////////////////////////////////////////////
88
//////////////////////////////////////////////////////////////////////////////
99

10-
void ProcessData() {
10+
void ProcessData()
11+
{
1112

1213
PopulateArray();
13-
14-
/*
14+
//
15+
/*
1516
// Print First Number
1617
Serial.println("---------");
1718
Serial.print("Motor 1: ");
@@ -50,31 +51,40 @@ void ProcessData() {
5051
//////////////////////////////////////////////////////////////////////////////
5152
//////////////////////////////////////////////////////////////////////////////
5253

53-
void PopulateArray() {
54+
void PopulateArray()
55+
{
5456

55-
//
57+
// temp string used to store the char array
58+
// easier to do opperations on string than chars
5659
String recieved_string = "";
60+
// give the string the value of the char array
5761
recieved_string = received_chars;
5862

63+
// now lets populate the motor command array with values from the recieved
64+
// string
5965
for (int i = 0; i < NUMBER_MOTORS; i++)
6066
{
6167
int search1 = (i * 2);
62-
int search2 = ((i * 2 ) + 1);
63-
68+
int search2 = ((i * 2) + 1);
69+
6470
String value1 = getValue(recieved_string, ',', search1);
65-
String value2 = getValue(recieved_string, ',', search2);
66-
67-
if (value1 == "Up") {
71+
String value2 = getValue(recieved_string, ',', search2);
72+
73+
if (value1 == "Up")
74+
{
6875
motor_commands[i][1] = 0;
6976
}
70-
else if (value1 == "Down") {
77+
else if (value1 == "Down")
78+
{
7179
motor_commands[i][1] = 1;
7280
}
7381

74-
else if (value1 == "None") {
82+
else if (value1 == "None")
83+
{
7584
motor_commands[i][1] = 2;
7685
}
77-
else if (value1 == "Reset") {
86+
else if (value1 == "Reset")
87+
{
7888
motor_commands[i][1] = 3;
7989
}
8090
else
@@ -96,14 +106,13 @@ void PopulateArray() {
96106
Serial.print(" - ");
97107
Serial.println(motor_commands[i][2]);
98108
}
99-
100-
101109
}
102110

103111
//////////////////////////////////////////////////////////////////////////////
104112
//////////////////////////////////////////////////////////////////////////////
105113

106-
void CheckSwitch(int switchPort) {
114+
void CheckSwitch(int switchPort)
115+
{
107116
// /* Step 1: Update the integrator based on the input signal. Note that the
108117
// integrator follows the input, decreasing or increasing towards the limits
109118
// as determined by the input state (0 or 1). */

0 commit comments

Comments
 (0)