This is what I found.
Timing problems are hard to track down, do the following:
Keep your foreground polling loops as small as you can. Us callback function as much as you can setOnxxx
Keep you onXxx function as small as you can.
I change to a sub fireMissile()
The changes in yellow did the most, the other changes where to find out what the code was doing
Hope this helps
When foreground loops are callback function get delayed getting called.
When callback functions are big other callback function get delayed getting called.
Wake the wait xxx as large as you can in the main loop
wait 50 in your loop is close to real time polling the getAccelerometer(). wait 100 is jerking.
Try changing the "Setting" so the "Auto-Init Variables" is tuned OFF.
All variables must be initialized before using them.
You will get a will get an error message indicating the uninitialized variable.
If "Auto-Init Variables" is tuned ON (ON is the default),
then any variable that is not initialized will be set to var$ = "" or var = 0.
When I first started the code would not run cause of uninitialized variable.
"trimx" was never initialized defaulted to zero, not a problem this time
When I change the indention I found some errors:
look at If…Then and If…Then…Endif
If…Then is on a single line
If…Then…Endif can't be on a single line
labels like attract: should end with a return.
Some time labels are required but I try to stay away from them
I put them in a sub labels() that way the variables are not global, I know the scope
sub attract() should end with a end sub
Use sub subName() it will make the variables local and only use global that are declared GLOBAL or CONST.
Keep the code scope as local as possible.
Use Const when you can set them and BASIC will error if you attempt to change that variable.
I work to keep GLOBAL to a minimum
This is what I followed converting your code.