
Re: nPgmTime Help with Gyro
There are many issues with your code. You can try the following:
Make sure the setHeading() function is called periodically in your robot main loop so it will keep integrating.
With your original code, the first problem is that heading is a local variable and will be destroyed when the setHeading function exits. So every time setHeading is called, the heading variable will get re-initialized back to 0.0 so you were not doing integration at all. So is prevTime, it doesn't survive across function entry and exit. Also, currTime and prevTime has the exact same value, so currTime - prevTime will always give you zero which you multiply to the Gyro reading thus giving you zero and then added to heading which again is 0 and so you get a ZERO.