tags:

views:

44

answers:

2
A: 

I don't see a declaration for "stop2" anywhere in your code...

Mr-sk
i've added in the program, its actually a big code. Anyways stop2 is just acting as flag in my case.....
abhilashm86
+1  A: 

Looks to me like you're confused about how to treat angles. Are you using a [0, 360] scale for a full circle or [-180, +180]? I see a check against 270 in your code, but your prose mentions -90. Yes, they're "the same", but if it's not working perhaps some confusion has crept into your code.

If you're going with [-180, +180], with zero degrees as the neutral position for your robot arm, perhaps you can take advantage of symmetry and use the absolute value function. You only have to code it once that way. If it's successful for [0, +90] it'll also work for [-90, 0] as well.

It also seems to me that you're not taking advantage of object-oriented thinking. This method has motion and timing and graphical refresh all in the same method. Writing smaller methods and unit testing each one to be sure that it works is a better approach. It's called "decomposition". The moment you say "it's a big method", it suggests to me that perhaps it's too big and needs to be refactored.

duffymo
yes i've a circular base, it can move 360 degree, i wanted 180 t0 -180 motion, i've declared an integer variable that cares about angle. Is there any better option else than static integer for representing angles?
abhilashm86
So why does your code have checks including 270 and 360? That's not [-180, +180]. "static" integer? Integer is good, but I don't understand "static".
duffymo