Go Down

Topic: Pin 13 blinks, and void loop doesnt loop (Read 1 time) previous topic - next topic

InvalidApple

Hey there

I find that when making a program that I now always make a function called "StopProgram".

It usually looks something like this:

Code: [Select]

void StopProgram(int A_variable) {

Serial.print(A_variable); // to see what a variable is doing at a certain point...

for(;;); //Program will stop here
}


The advantage of using this is that you can debug your program one line at a time.

Also, if you are having trouble with:

Code: [Select]

   if (Cstate >= 10000 && Cstate <= 19999){
     zoCommandVelocityMove(NodeID,5000);
     delay(3000);
   }

   else if(Cstate >= 20000 && Cstate <= 29999){
     int i = Cstate - 20000;
     zoCommandRelativePositionMove(NodeID,i);
     delay(3300);
   }

   else if(Cstate >= 30000 && Cstate <= 39999){
     int i = Cstate - 30000;
       zoCommandAbsolutePositionMove(NodeID,i);
       delay(3300);
     }
   }


... Maybe you could try:

Code: [Select]

   if (Cstate >= 10000 && Cstate <= 19999){
     zoCommandVelocityMove(NodeID,5000);
     delay(3000);
   }

   else {
     Long i = Cstate % 10000;    //<-----See below
     zoCommandRelativePositionMove(NodeID,i);
     delay(3300);
   }


------> because Cstate is not an integer: It is a "Long".

Hope all goes well :)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy