Adding Hit sensor to targets

I am trying to add a hit sensor to my target. I use one servo to lift then get out of the way, the shooter has 3 seconds to hit the target. If they miss it then the other servo comes up and knocks the target down. I am using a normally closed contact mounted on the base and the magnet mounted on the target. So up will give you an open an down will give you a closed. I need to input this into the Maestro and give a signal to the target software. When the target is up it should be low. When it is down it will be high. The problem is that I only want the out put to be active between when the target is lifted and when the down servo comes up to knock it down. If during that window the circuit goes high, it will be logged as a legitimate hit. Here is the code that makes 1 target work:

9000 0 servo
600 delay
4000 0 servo
3000 delay
4000 1 servo
500 delay
8000 1 servo
500 delay
4000 1 servo
2000 delay
Repeat

I know I need a subroutine that is waiting during the 3 seconds the target is up as well as checking the status of the input. If it sees the input go high during that delay then BANG, the out put sends the trigger to the scoring unit. Anything outside of that window should not trigger the output.

I am also having trouble with a command to pause a script at a designated point and then start it up again with a button press. Lets say I have 7 of these targets repeating the above sequence and I need to stop every three targets to tell everyone to reload and then hit a button when everyone is ready. I know I need something that will keep the script in a loop until the button is pressed and I have tried the code in the manual but nothing is working. I am really trying to dot homework here but I have hit a brick wall. Please help!

SGT Thompson
US Army

BTW- I called Pololu today and spoke to Ryan. He said the Maestro can do all of this and suggested I post here on the forum for assistance. I gave up on the button issue and will just take the one sequence with pauses and make 3 more scripts. I just need some guidance on how to have an output only be active between 2 lines of code in my script. I have not found anything anywhere on this topic.

Hello SGT Thompson,

You might consider sampling the output directly after the 3000ms delay, instead of monitoring it for the full three seconds. You could use the get_position command to check the state of your output and register a point if your output is high. Also, you could use the same if statement to have the second servo only clear the target if your output was low (the target is still up). If you need help implementing this in the script, please let me know.

-Brandon

Thanks Brandon! I won’t be able to get back to it until Wednesday but I will let you know how it works.