E - energy in Jules
W - Weight of pendulum
g - gravitational acceleration(9.80665 m/s2)
R - Lenth of the pendulum from pivot pont
Cos a - Starting angle
Cos B - ending angle
L - energy lost

This is a pendulum with a weight and I will be using starting angle of the pendulum (cos a) and the first point of reversal (cos b) to calculate the energy in Jules lost (E).

Maths is really not my strong suit, and I could really do with some help on how I calculate the cos to put into the formula based on the degrees of rotation.

MorganS: cos() works, so long as you put the angle in radians.

So, if I take my degrees from converting the 400 points from the encoder im using by dividing 400/360 I can then use that value × pi/180 and use cos()?

MorganS:
Make sure the result of the intermediate calculation is a float. Just dividing integer by integer will give you an integer and you need the decimals.

The PI macro is a float, so that will force a type conversion in jremington's code.

To be totally honest, this project is probably so far above my coding skill level I will end up paying someone on Fiverr, and try and learn from their code.

Mechanical and electrically sound, but I just can't code, just can't get it to click, and have so many projects that never got out the notebook dude to my inability to grasp the basics.