I've created the following function:

void runMotor(int _dir, int _step, int wait){
  digitalWrite(_dir, HIGH);
  for (int x = 0; x < 3200; x++) {
    digitalWrite(_step, HIGH);
    digitalWrite(_step, LOW);

In the first line inside the function I used the value HIGH as a fixed value. I would like to know if there's a way to pass the values HIGH and LOW as a parameter in this function. Is it possible?

Or should I just create a new function to rotate my step motor to the other side?

  • HIGH is just an alias for the number 1. LOW is just an alias for the number 0. Anywhere you can use numbers you can use HIGH or LOW equally. You can even use them in math: HIGH + HIGH == 2. The same goes for things like INPUT, OUTPUT, RISING, FALLING, etc. They are just aliases to numbers.
    – Majenko
    Commented Oct 15, 2016 at 11:48

1 Answer 1


digitalWrite expects the pin and value to be uint8_t type. So you can certainly pass LOW or HIGH to functions.

For example:

void runMotor(int _dir, int _step, int wait, uint8_t value){
  digitalWrite(_dir, value);
  • What about Analog pins? Are they expected to be uint8_t values as well?
    – Ramuyko
    Commented Oct 18, 2016 at 4:02
  • I meant what about the analogRead() function...
    – Ramuyko
    Commented Oct 18, 2016 at 12:29
  • What do you mean? You don't pass HIGH or LOW to analogRead. You mean the pin numbers? Yes the pin number is uint8_t as well.
    – Nick Gammon
    Commented Oct 18, 2016 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.