Ok. I understand what you mean by changing it to a switch statement, but unfortunately I JUST learned what they were about 2 weeks ago in AP computer science A in school. So, I've had little experience working with them. How might I change this into a switch statement?
Also, I would actually be running this motor in 2 directions. The first direction (forward) would draw back the rope and lift up the forklift. Position 1 is the ground position, 2 is the 1st layer on the spider, 3 is the 2nd layer on the spider, and 4 is the 3rd (highest layer) on the spider. Then it would need to come back down.
So let's say I kept the code as is, but added the if(pwm03 != 127) over the entire thing, both the if(rc_dig_in04 == 1) and the if(count == 8)...then could that also satisfy this?
Quote:
|
4. After you set pwm03 to 127, the tape is still sitting in the sensor, and the sensor is still reading 1. So when you start up the motor again, the sensor will still say 1, and you'll instantly stop. You should add in code that waits until rc_dig_in04 goes back to 0 before you start checking for it to be 1 again.
|
Also, I agree with changing rc_dig_in04 (previously digital_io_04) to the now last variable set up that you suggested. (I'm kind of talking to both of you now).