I am trying to do it such, that, for each loop inpSpeedS[0-3] is assigned a new value, which then determines the speed of the two DC motors, that are hooked to an H-bridge.
My problem is, that it will not progress past loop1 for input1.
Does anyone know the solution to this/why this is happening?
int Speed = 0;
const int motinp1 = 2;
const int motinp2 = 3;
const int motinp3 = 4;
const int motinp4 = 5;
int inpSpeedS[4]; // An array to determine the speed of each individual input
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(motinp1, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Booleans for changing motor input
boolean valueInp1 = false;
boolean valueInp2 = false;
boolean valueInp3 = false;
boolean valueInp4 = false;
//Motor driving functions times 4
if (Serial.available () && valueInp1 == false && valueInp2 == false && valueInp3 == false) {
inpSpeedS[0] = Serial.parseInt();
Serial.print("Input 1: ");
Serial.print(inpSpeedS[0]);
delay(500);
boolean valueInp1 = true;
Serial.println(valueInp1);
return inpSpeedS[0], valueInp1;
}
else if (Serial.available () && valueInp1 == true && valueInp2 == false && valueInp3 == false) {
inpSpeedS[1] = Serial.parseInt();
Serial.println("Input 2: ");
Serial.print(inpSpeedS[1]);
delay(500);
valueInp2 = true;
return inpSpeedS[1], valueInp2;
}
else if (Serial.available () && valueInp1 == true && valueInp2 == true && valueInp3 == false) {
inpSpeedS[2] = Serial.parseInt();
Serial.println("Input 3: ");
Serial.print(inpSpeedS[2]);
delay(500);
valueInp3 = true;
return inpSpeedS[2], valueInp3;
}
else if (Serial.available () && valueInp1 == true && valueInp2 == 0 && valueInp3 == true) {
inpSpeedS[3] = Serial.parseInt();
Serial.println("Input 4: ");
Serial.print(inpSpeedS[3]);
delay(500);
valueInp1 = false;
valueInp2 = false;
valueInp3 = false;
valueInp4= false;
return inpSpeedS[3],valueInp1, valueInp2, valueInp3; valueInp4;
}
delay(500);
analogWrite(motinp1, inpSpeedS[0]);
analogWrite(motinp2, inpSpeedS[1]);
analogWrite(motinp3, inpSpeedS[2]);
analogWrite(motinp4, inpSpeedS[3]);
}