Automated Rock Wall

Hi all, senior in electro-mechanical engineering technology here building his capstone project. It is an automated rock climbing wall and we are in the code writing process. There are some ws2812 LEDs that are being annoying too, but lets focus on the motor itself now.

This motor will be controlled by 3 sensors, a deadman, top sensor and bottom sensor. The deadman sensor will allow the entire program to run if high. Assuming this condition is met and the top sensor is activated the motor will run until the bottom sensor is activated. So the top sensor will cause the motor to run and the bottom sensor will cause the motor to stop. I have been playing with a while/if/elseif program and I just started looking at this case machine by wildbill What have I done right/wrong? - #9 by wildbill - Programming Questions - Arduino Forum. I am more familiar with the while/if/elseif but I think I like how the case program works more, although I admittedly don't fully understand it.

It is now time to seek help because what seems like a simple task is turning out to be not so much.


int motorPin = 2;                 // motor leads connected to digital pin 2
int sensord = 3;                  // Deadman sensor connected to digital pin 3
int sensort = 4;                  // Top sensor connected to digital pin 4
int sensorb = 5;                  // Bottom sensor connected to digital pin 5

void setup()
  pinMode(motorPin, OUTPUT);      // sets the digital pin as output
  pinMode(sensord, INPUT);
  pinMode(sensort, INPUT);
  pinMode(sensorb, INPUT);

void loop()
while (sensord == HIGH)//digitalWrite(motorPin, HIGH);    // allows climbing track motor to run
  if (sensort == HIGH)
       digitalWrite(motorPin, HIGH);
   else if (sensorb == HIGH)
      digitalWrite(motorPin, LOW);

I'm not really following why the Arduino is involved in this solution. Can't the behaviour you're describing be achieved by wiring three switches in series?

It can but the project requires some automation so we are trying to use the arduino for that. Plus it will be running the lights so we figured why not?

So what happens when you run the code that you have ?

The number of the pin and the state of that pin bear a relationship, discovered by digitalRead(). You are currently not reading the state of the switches. Instead, you are testing the pin numbers. Why?

Hi all, senior in electro-mechanical engineering technology here building his capstone project.

Incredible that you are a senior, and making such a colossal blunder.

PaulS, no excuses, I just plain forgot about that. My arduino class was 3 years ago, I am pretty rusty with them and my preferences lie elsewhere. I will take what you said as constructive critisizm and not a personal shot and I will look into this further.

I figured I wasn't getting any input because when the program is run, either the motor runs continuously or nothing happens, I was unsure how to remedy this though.

and not a personal shot

It wasn't really meant as a personal shot. But, when I got my engineering degree, I took a lot of computer programming courses at the same time, because I could see that they were going to be useful. I got my degree in 1979. I can't imagine that there is any less need to be able to write computer programs now than there was then. So, when people come in here wanting help writing basic code as part of a capstone project for some seemingly engineering related degree program, I'm amazed. It just seems like programming ought to be second nature by then.

Code based is something my degree doesn't heavily push, it is something you can take extra though. We focus more on PLCs/HMI and Matlab/Labview. We do much more with automation via those than any code writing. Anyway, back to the issue at hand.

We do much more with automation via those than any code writing.

That's a shame, in my opinion. Using tools that someone else has written is fine, once you know how they did it.