Motor moving back and forth at different speeds

Hi Guys,

I have a motor that moves an object back and forth. However, I actually need it to move forward at a faster rate than it moves backward. How can I implement different (constant) speeds for these two directions?

I did not write the code myself and am quite new to Arduino. There is some part in there about a "relais perslucht ventiel" but this is not important for the setup.

Cheers!

int IN1 = 4; // pin 4 int IN2 = 5; // pin 5 int speedPinA = 9; // Pin 9 voor de PWM modulatie om de snelheid van de motor te variƫren

include "HX711.h"

define DOUT 3

define CLK 2

// aansturing relais perslucht ventiel int IN3 = 8; // pin 8 als output naar relais

// schakelaars informatie------------------ int sensorPinleft = A0; // input pin lichtsluis links int sensorPinright = A1; // input pin lichtsluis rechts int spindirection= 1; // 1 voor rechtsom

void setup() { // Set the output pins pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(speedPinA,OUTPUT); pinMode(IN3, OUTPUT); Serial.begin(9600); Serial.println("Toets T en enter om te nullen"); scale.set_scale(-1574650); //Calibration Factor obtained from first sketch scale.tare(); //Reset the scale to 0

}

// Program ================================================================

void loop() // Motorsturing--------------------------- { analogWrite(speedPinA, 255); sensorPinright = analogRead(A0); sensorPinleft = analogRead(A1);

//============ IF constructie ==========

if (sensorPinlinks > 500) { spindirection= 0; }

if (sensorPinrechts > 500) { spindirection= 1;

}

Right, first things first.

Please go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code (but it needs to be the complete code) as such so we can examine it conveniently and accurately. Please do not post a ".ino" file as an attachment - that would mean that you are expecting people to actually load it to their IDE to look at it and that is extra unnecessary labour. In fact, attachments do not always show properly on different operating systems.

If you do not mark it up as code, the code you post could well be garbled and is certainly anything but easy to read.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

And - before you post any code, use "Auto Format" in the Tools menu of the IDE to properly present the code.

Try and avoid unnecessary white space (blank lines). You should only use these to separate functional blocks of code.