PDA

View Full Version : [Question(s)] Executes Program Only Once



raecom1
07-28-2014, 10:27 AM
Hello!

New to programing so I thought I would ask the pro's in here.

Question: Using Dynamixel AX-12W Servo with Arbotix-M Controller. I made my program and it runs well (series of left and right servo movement's). How can I get the program to run once then shut off until it receives power again?

I will be using a coin operated timer similar to a car wash quarter timer, to power the Arbotix power then in 2 minutes the timer will cut power off until another quarter is placed in it. This way the servo starts/stops at the same position each and every time.

Could someone give me some insight on what type of code I need and were to put it in the string.

Thanks very much..

tician
07-28-2014, 10:47 AM
If you are talking about an arduino sketch, then you simply add
while(1); to the end of the 'void loop()' function. At that point, the program will simply wait indefinitely until the arduino is rebooted.

raecom1
07-28-2014, 05:21 PM
Thanks for your response. Sorry for being so new to this, where using the below code would you place this command. Thanks again in advance.


//import ax12 library to send DYNAMIXEL commands
#include <ax12.h>
void setup()
{
SetPosition(1,0); //set the position of servo # 1 to '0'
delay(100);//wait for servo to move
}
void loop()
{
//increment from 0 to 300
for(int i=0;i<300;i++) //moved from 0 to 600

raecom1
07-28-2014, 05:33 PM
Just figured it out and it works as needed, (long day at work). Thanks so much for your help.