Mini elevator project

I am looking to start a project using an Arduino UNO and Arduino motor shield. I really just need help with the programming and inputs. I am looking to use a real elevator controller to move the miniature elevator. First of all which type of motor. The load will be counterweighted to help alleviate some torque requirements. I was thinking a brushed motor with a gearbox or stepper motor would work well. I am not worried about positioning as all that is done by the elevator controller.

In a nutshell... I have 4 contacts coming from the elevator controller consisting of
UpFast
UpSlow
DnFast
DnSlow
High speed consists of fast and slow made up at the same time while leveling speed is just slow made up. I need to program the arduino to look,at these inputs and generate a direction and speed. I was thinking an if statement may work with multiple qualifiers.
Like:
If (upslow == HIGH) and (upslow == HIGH);
DigitalWrite brake off
Digital write forward direction
Analog write 255

I know that is not proper syntax but you get the idea. Am I on the right track or should I be looking at a different approach to the programming?

If (upslow == HIGH) and (upslow == HIGH);
DigitalWrite brake off
Digital write forward direction
Analog write 255

Am I on the right track

Well, that semicolon will screw things up. If you get rid of that, and use curly braces and proper syntax (and actually read the pins), then you are on the right track. Sort of.

I am not worried about positioning as all that is done by the elevator controller.

Based on what input? It has to know where the floors are and where the car is.

I have 4 contacts coming from the elevator controller

What voltage?

I know the code is all messed up just trying to see if I am even close. The positioning will be read by the elevator controller using proximity switches. I have dry contacts on relays I added to the controller for up fast, upslow, dnslow, and dnfast. I can use the 5volts arduino control power to run through the relay contacts. The elevator controller will basically tell arduino when to run, what direction, and at what speed and when to stop based on the speed outputs from the controller. I will write some code and post so you guys can pick it apart :slight_smile:

Thanks for the reply...

I will write some code and post so you guys can pick it apart review it

There, I fixed that for you.

OK here is the code I came up with:

// give the motor control pins names:
const int pwmB = 11;
const int brakeB = 8;
const int dirB = 13;
const int upslow = 2;
const int upfast = 4;
const int dnslow = 5;
const int dnfast = 6;

void setup() {

//Setup Channel B
pinMode(dirB, OUTPUT);
pinMode(brakeB, OUTPUT);
pinMode(upslow, INPUT_PULLUP);
pinMode(upfast, INPUT_PULLUP);
pinMode(dnslow, INPUT_PULLUP);
pinMode(dnfast, INPUT_PULLUP);
}

void loop(){

if (upslow == LOW and upfast == LOW) {
digitalWrite(dirB, HIGH);
analogWrite(pwmB, 255);
digitalWrite(brakeB, LOW);
delay(10000);
}
else if (upslow == LOW and upfast == HIGH) {
digitalWrite(dirB, HIGH);
analogWrite(pwmB, 96);
digitalWrite(brakeB, LOW);
delay(10000);
}
else if (dnslow == LOW and dnfast == LOW) {
digitalWrite(dirB, LOW);
analogWrite(pwmB, 128);
digitalWrite(brakeB, LOW);
delay(10000);
}
else if (dnslow == LOW and dnfast == HIGH) {
digitalWrite(dirB, LOW);
analogWrite(pwmB, 128);
digitalWrite(brakeB, LOW);
delay(10000);
}

digitalWrite(brakeB, HIGH);

delay(4000);

}

I tried to take input 2 to ground and I get no output to the motor. Not sure what I am missing. Do the inputs still work the same on the motor shield?

Not sure what I am missing.

Calls to digitalRead(), for one thing.

const int upslow = 2;
const int upfast = 4;
  if (upslow == LOW and upfast == LOW) {

I think that it is pretty obvious that 2 is not LOW and that 4 is not LOW.

Do the inputs still work the same on the motor shield?

What inputs does your motor shield have?

Calls to digitalRead(), for one thing.

I see that I am not reading the input I will add that...

I think that it is pretty obvious that 2 is not LOW and that 4 is not LOW.

I thought input_pullup was high until pulled low by grounding the pin... Am I missing something?

What inputs does your motor shield have?

Not sure? I guess I assumed that the pins that aren't marked are spare. It is an Arduino v3.

Please give some advice

I thought input_pullup was high until pulled low by grounding the pin... Am I missing something?

Yes. The number of a pin and the state of that pin are two completely different things. You MUST read and base decisions on the state of the pin, not the pin number.

what i would suggest before going any further is to properly read the documentation on the arduino website..
as i see your coding, it migth be ahrd to make a working sketch if you don't know you have to read a port in order to know its state.

I guess that's the first step you normally do before starting something, is to read some basic information on the topic