more than 1 input

Hi! Is it possible to have more than 1 input in arduino?

example. i have 2 stepper motors and choose 1 to run first (lets say choose between 1 or 0) (1st input) , and then i assign how many revolution the selected motor is going to have (2nd input).

or Im thinking if i can only input the number of revolution, but i dont know how to disable the other at the same time. Thank you!

Is English your first language?

No, sorry :slightly_frowning_face:

wentaw:
No, sorry :slightly_frowning_face:

Oh, no problem, you are then excused. First tell us what kind of input you have in mind. Do you mean typed in commands from the serial port?

first, this code works, but all steppers are moving after the other

#include <Stepper.h>
#define rev 900
#define rev1 900
Stepper myStepper(rev, 8, 9, 10, 11);
Stepper myStepper1(rev1, 4, 5, 6, 7);
int val;

void setup() {

  myStepper.setSpeed(60);
  myStepper1.setSpeed(60);
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 0 )
  { 
  }
    val = Serial.parseInt();
    {
      while (val > 0)
      {
        Serial.println(val);
        myStepper.step(4550);
        delay(10);
  
        val--;
      }
    }

    {
      while (val> 0)
      {
        Serial.println(val);
        myStepper1.step(5900);
        delay(10);
        

        val--;
      }
    }
 

}

i dont know how to disable the other stepper

aarg:
Do you mean typed in commands from the serial port?

all i know is that typed in command but only the first input (revolution) in the arduino will read.

The steppers are moving one after the other because your two control loops run one after the other.

how can i change it, i dont know what to do next? I tried changing the codes but the program wont work anymore so i return it like that. and thinking of other options like disabling the other so that it will not run after the 1st stepper stops. but i cant come up with other idea, cause most of the questions here in forum, they want to run their motors simultaneously.

Collect the input with 2 parseInts, then run 1 control loop using the two variables that you converted with parseInt.

So, like val1 and val2. Thing is, the loop will have to run for the number of times of the greatest value of the two.

Sorry i am not familiar in some terms here. how can i collect the input o the 2 parseints?

i tried changing tha val to val1 and add val2. but only one stepper is moving, i cant run the other

wentaw:
Sorry i am not familiar in some terms here. how can i collect the input o the 2 parseints?

One after the other. parseInt and then parseInt again.

When you modify code, please post it again so we can see the changes.

i changed it but its randomly running one of the motors.

can i use sarial.read? when choosing 1 of the steppers? using vb 2010?

We have no idea what your code looks like now.

#include <Stepper.h>
#define rev 900
#define rev1 900
Stepper myStepper(rev, 8, 9, 10, 11);
Stepper myStepper1(rev1, 4, 5, 6, 7);
int val1, val2;

void setup() {

  myStepper.setSpeed(60);
  myStepper1.setSpeed(60);
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 0 )
  { 
  }
    val1 = Serial.parseInt();
    val2 = Serial.parseInt();
    {
    
      if (val1 > val2)
      {
        Serial.println(val1);
        myStepper.step(450);
        delay(10);
  
        val1--;
      }
      else if (val1<val2)
        {
        Serial.println(val2);
        myStepper1.step(590);
        delay(10);
        

        val2--;
      }
      else
      {
        
      }
    }

 

}

this is what i understand sorry if its wrong

  if (Serial.available() > 0 )
  {
  }

This means, "If there are characters to read, do nothing at all".

aarg:

  if (Serial.available() > 0 )

{
  }




This means, "If there are characters to read, do nothing at all".

so its okay if i remove this?

is it possible to just disable one of the stepper inside of this code?

 mot = Serial.parseInt();

      while (mot >0)
      {
        Serial.println(mot);
        myStepper.step(-450);
        delay(10);
        mot--;
      }

so whenever I input a value for revolution only one stepper will run