@@ -14,7 +14,9 @@ boolean newData = false;
14
14
15
15
String recievedString = " " ;
16
16
17
-
17
+ int number_of_motors = 2 ;
18
+ // int rotation_int[number_of_motors];
19
+ // motor 1 variables
18
20
int m1_sensor_pin = A0;
19
21
int m1_sensor_value1 = 0 ;
20
22
int m1_sensor_value2 = 0 ;
@@ -36,7 +38,7 @@ void setup() {
36
38
pwm.begin ();
37
39
pwm.setPWMFreq (50 );
38
40
delay (10 );
39
- pwm.setPWM (3 , 0 , 0 );
41
+ pwm.setPWM (0 , 0 , 0 );
40
42
}
41
43
42
44
void loop () {
@@ -88,19 +90,32 @@ void processData() {
88
90
m1_rotation_direction = getValue (recievedString, ' ,' , 0 );
89
91
m1_rotation = getValue (recievedString, ' ,' , 1 );
90
92
m1_rotation_int = m1_rotation.toInt ();
93
+
94
+ m2_rotation_direction = getValue (recievedString, ' ,' , 2 );
95
+ m2_rotation = getValue (recievedString, ' ,' , 3 );
96
+ m2_rotation_int = m2_rotation.toInt ();
97
+
91
98
92
- // comments
99
+ // serial print info
93
100
Serial.println (" <" );
94
101
Serial.print (" RevievedString: " );
95
102
Serial.println (recievedString);
96
- Serial.print (" Number of Rotations: " );
103
+ Serial.println (" Number of Rotations: " );
104
+ Serial.print (" m1: " );
97
105
Serial.println (m1_rotation);
106
+ Serial.print (" m2: " );
107
+ Serial.println (m2_rotation);
108
+
109
+
110
+ // while all motors aren't ready
111
+
112
+
98
113
99
114
if (m1_rotation_direction == " Up" ) {
100
115
Serial.println (" <" );
101
116
Serial.print (" Arduino: " );
102
117
Serial.println (" Moving Up!" );
103
- upMotor (3 );
118
+ upMotor (0 );
104
119
while (1 ) {
105
120
readValues ();
106
121
Serial.println (m1_sensor_value2);
@@ -113,13 +128,13 @@ void processData() {
113
128
}
114
129
delay (500 );
115
130
}
116
- stopMotor (3 );
131
+ stopMotor (0 );
117
132
}
118
133
else if (m1_rotation_direction == " Down" ) {
119
134
Serial.println (" <" );
120
135
Serial.print (" Arduino: " );
121
136
Serial.println (" Moving Down!" );
122
- downMotor (3 );
137
+ downMotor (0 );
123
138
while (1 ) {
124
139
readValues ();
125
140
Serial.println (m1_sensor_value2);
@@ -132,14 +147,14 @@ void processData() {
132
147
}
133
148
delay (500 );
134
149
}
135
- stopMotor (3 );
150
+ stopMotor (0 );
136
151
}
137
152
138
153
else if (m1_rotation_direction == " Stop" ){
139
154
Serial.println (" <" );
140
155
Serial.print (" Arduino: " );
141
156
Serial.println (" Moving Stopping!" );
142
- stopMotor (3 );
157
+ stopMotor (0 );
143
158
}
144
159
else
145
160
{
0 commit comments