5

I am building a robotic hand, and I programmed the finger to close when the touch sensor is pressed, and release when the touch sensor is released. It did that with a loop block - enter image description here

but when I ran this the finger kept holding down. I could tell because when I tried to gently tug on the motor, it wouldn't budge.

Can anybody tell me what's going on?

3

Your code instructs the motor to continuously turn in one direction, and because you chose a motor block in the “on” mode, it will continue to turn even during the loop condition check. The loop condition says the loop will continue as long as the button is released (AFAIK, I don’t have an EV3 close by currently to validate this), which means that it does exactly the opposite of what you intended. Change the loop condition to loop as long as the touch sensor is pressed and you will fix this issue. Plus, once the loop finishes, the motor will still continue to turn; you would need to put a Motor block in the “off” mode directly after the loop.

  • That's what I thought, but I was wrong. The loop goes until the parameter is true. The loop will go until the touch sensor is released. – legomyleg Jan 6 '18 at 3:07
  • Even if that’s true, the lack of a “motor off” block immediately after the loop is why the hand keeps gripping. – Phil B. Jan 6 '18 at 3:10
  • Also, the "on" block only turns the motor on for the duration of the next blocks run time. If you had the blocks "motor on", "wait 1 sec", and "play sound" in that order, the motor would stop before the sound played. – legomyleg Jan 6 '18 at 3:11
  • 1
    Nevermind, I was wrong – legomyleg Jan 6 '18 at 3:14
0

Code for robotics finger What your current code does is to keep closing the finger until you press the sensor. This code may help.

You might need to change the 180 degrees boxes according to how many degrees the motor has to turn to close the finger.

0

You need to stop the motor after the loop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.