Go Down

Topic: Opinions and improvements to my MotorControl-Function for the ArduinoMotorShield (Read 239 times) previous topic - next topic

EATEX

Hello guys,

This is my first self-written function (with Testingprogram) and I am interested in what you think about it and your suggestions for improvements.

Quote
void setup(){}

void loop(){
  MotorControl(3, 12, 9, 155, HIGH, LOW);
  delay(3000);
  MotorControl(3,12,9,0,HIGH, HIGH);
  delay(5000);
  MotorControl(3,12,9,255,LOW, LOW);
  delay(3000);
  MotorControl(3, 12, 9, 0, HIGH, HIGH);
  delay(1000);
}


void Motor(byte pinPWM, byte pinDirectionM, byte pinBrakeM, int value_PWM, boolean value_directionM, boolean value_brakeM){
  constrain(value_PWM,0,255);
  pinMode(pinBrakeM, OUTPUT);
  pinMode(pinDirectionM, OUTPUT);
  digitalWrite(pinBrakeM, value_brakeM);
  digitalWrite(pinDirectionM, value_directionM);
  analogWrite(pinPWM, value_PWM);
}
I wrote it in order to save space  because I have to Control 6 different DC-Motors with an Arduino Mega + 3 MotorShields.

Thank you and sorry for my english :-)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy