2D Accelerometer
Ok so what exactly is going on :O
Firstly, I got the program from another site which rotates the shape, because I am nowhere near capable of doing something like that. However what I did was take the accelerometer I had handy (Which outputs an analog voltage based on the ammoutn of G's its feeling.
For those who aren't physisists, 1 G is the equivalent of one gravity force, or what we feel every day. The sensor outputs 0 g's at half V+ which in my case is 2.5V (I assumed 5V power source). As you tilt it, it will feel a fraction of 1 G. It will actually feel the sine of the angle it is tilted at times 1G. To find out the angle it is tilted at , we need to take the arcsine of the G force.
The pic 16f628a reads the analog voltages coming from the sensor on the X and Y axis and sends them to my laptop via RS232. It does this by using the pic's internal UART hardware and bumping those signals up to normal rs232 voltages using a max232. The laptop then uses the C# program which I modified and converts the voltages into an angle and refreshes the window.