, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here
I can not seem to get the "Forward/stop/Reverse" code. I do not know what I am doing wrong. Maybe I am missing something.
Here is what I am trying to do.
I need a piece of code that will allow me to press one button on the mobile interface and make a continuous servo move forward for a desired amount of time (say 3 seconds) then I need it to stop during which time I need a normal servo to move to a set position then once it has reached that position I then need the continuous servo to reverse back for 3 seconds.
Basically I am making a static BB8 and I want him to to do the thumbs up. I have made the code for his panel/door to open and close. Now I need the code for his arm to roll out then the torch flip up and down and then the arm roll back into his body.
I can make the arm move forward when a button is pressed but it wont stop unless I make a separate stop button.
Any help would be great, thank you.
I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.
Also, consider reviewing the Learn section for informative lessons and activities.
Check it out!
Forward() is only applicable with a Movement Panel. The command forward() without a Movement Panel has no concept of what "forward" is. Forward is an action but the robot doesn't know how to move. It's like telling a table to move forward. Or telling a pine tree to move forward. They probably could move forward if they knew how.
There are a number of Movement Panels, and each uses different hardware. There are HBridge Movement Panels, Auto Position (for gait), continuous rotation Movement Panel, etc...
So a Movement Panel is how something can move. This is not to say that you robot "needs" a Movement Panel. Although a Custom Movement Panel allows you to add your own script code so the commands Forward(), etc... will actually do something.
You can do something like this with continuous rotation servos without a Movement Panel...
# move servo one direction at the speed of 120 (90 is the center point)
# wait 3 seconds
# stop the servo from moving
However, are you certain that you're using continuous rotation and not Standard Servos? Because there are generally no use-cases for continuous rotation servos outside of wheels.
Thanks, Yes I am using a continuous servo, because a normal servo wasn't moving the arm far enough in a 180 degree turn of the large cog wheel I had. I needed to use a continuous servo so the cog would turn enough to move the arm out far enough. I knew about the Movement Panel and have one on the screen this is how I was able to get it so that when a button is pressed the servo moves forward, I just couldn't get it to stop and reverse after a set length of time without having to make all those actions as separate buttons. I wanted it so that one button press would make the continuous servo move forward for a set amount of time then stop and wait for a set amount of time and then reverse back again.
Here is a picture of what I mean and why I am using a continuous servo.
DJ, I just messed around with the piece of code you gave me and it works perfectly for what I need. Thank you so much, awesome as always!.
Excellent to hear! Can't wait to see this guy completed!