How does the robot know what pos his servo is at?

i realize the servo is only connected to an "out" pin. is there some popular method people use to have the servo tell us:

"ive arrived at my destination"

My purpose is to have the sonar fire when the servo is at a specified location. w/o relying on iffy pause timers. (which stop everyhting else from what i know)

Yup.

Your code already knows where the servo is! During a servo “sweep” simply have the sonar fire when the positions are at 75 150 175 or anywhere else you want it to. You will need to fiddle with the length of pause after the servo command to be sure it has had time to get there or depending on how you coded the “sweep” the “sonar” code simply comes after the “move the servo” code and by default the sonar has to fire before the code moves to the next line and moves the servo again.

 

Did that make any sence at all?!?!

I’m an idiot

www.rocketbrandcustom.com baby!!

I think you are a nice guy.
I think you are a nice guy.

There is no such

There is no such return.

However, provided your servo has same voltage and load, it is quite precise in the timing.

And so you can… hey wait - I wrote about this at… https://www.robotshop.com/letsmakerobots/node/24

Oh, and regarding "timers" stopping everything;

A) Picaxe (and other microcontrollers) have "interroupts" / Timers that you can set… however…

B) If you make your code do cycles with ongoing counters that control everything instead of just firing it all and then trying to catch what is happening first, you will not need a timer, and have better control than with it. Example, pseudo code:

Count A from 75 to 90
Position server X at A
Go sub other_loop (Pause from this, wait till the servo is finished moving)
IF A (and now also server X) is = 80, then… what you wanted to do…
go back in loop

Other loop:
(do anything else, like check if we are hitting something or something is pressed etc)
Return

This was extremely helpful.
This was extremely helpful. I had a successful "rewrite code" party tonight. Thanks :slight_smile: