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

Commit 6303164

Browse files
Demo (06/06/2018)
1 parent a5f4ca2 commit 6303164

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

arduino_control/arduino_control.ino

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ boolean newData = false;
1414

1515
String recievedString = "";
1616

17-
17+
int number_of_motors = 2;
18+
//int rotation_int[number_of_motors];
19+
// motor 1 variables
1820
int m1_sensor_pin = A0;
1921
int m1_sensor_value1 = 0;
2022
int m1_sensor_value2 = 0;
@@ -36,7 +38,7 @@ void setup() {
3638
pwm.begin();
3739
pwm.setPWMFreq(50);
3840
delay(10);
39-
pwm.setPWM(3, 0, 0);
41+
pwm.setPWM(0, 0, 0);
4042
}
4143

4244
void loop() {
@@ -88,19 +90,32 @@ void processData() {
8890
m1_rotation_direction = getValue(recievedString, ',', 0);
8991
m1_rotation = getValue(recievedString, ',', 1);
9092
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+
9198

92-
//comments
99+
//serial print info
93100
Serial.println("<");
94101
Serial.print("RevievedString: ");
95102
Serial.println(recievedString);
96-
Serial.print("Number of Rotations: ");
103+
Serial.println("Number of Rotations: ");
104+
Serial.print("m1: ");
97105
Serial.println(m1_rotation);
106+
Serial.print("m2: ");
107+
Serial.println(m2_rotation);
108+
109+
110+
// while all motors aren't ready
111+
112+
98113

99114
if (m1_rotation_direction == "Up") {
100115
Serial.println("<");
101116
Serial.print("Arduino: ");
102117
Serial.println("Moving Up!");
103-
upMotor(3);
118+
upMotor(0);
104119
while (1) {
105120
readValues();
106121
Serial.println(m1_sensor_value2);
@@ -113,13 +128,13 @@ void processData() {
113128
}
114129
delay(500);
115130
}
116-
stopMotor(3);
131+
stopMotor(0);
117132
}
118133
else if (m1_rotation_direction == "Down") {
119134
Serial.println("<");
120135
Serial.print("Arduino: ");
121136
Serial.println("Moving Down!");
122-
downMotor(3);
137+
downMotor(0);
123138
while (1) {
124139
readValues();
125140
Serial.println(m1_sensor_value2);
@@ -132,14 +147,14 @@ void processData() {
132147
}
133148
delay(500);
134149
}
135-
stopMotor(3);
150+
stopMotor(0);
136151
}
137152

138153
else if (m1_rotation_direction == "Stop"){
139154
Serial.println("<");
140155
Serial.print("Arduino: ");
141156
Serial.println("Moving Stopping!");
142-
stopMotor(3);
157+
stopMotor(0);
143158
}
144159
else
145160
{

0 commit comments

Comments
 (0)