Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by DJ Sures!

Can Someone Help Me Write A Piece Of Code?

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.


Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!

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)
servo(d0, 120)

# 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.

User-inserted image
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!