Blackdragon,
You do not need to get bogged down in the maths of the floating point number. My code example shows how to change the 4 bytes received to a float. Its very similar to the example from the website, which you also found. The technique is to put the 4 received bytes at the same addresses as the float variable, then ask the computer to interpret the float value. The arduino already 'knows' that if it is given a float, how to manipulate it. You don't have to know.
look at this code, from your example:
for (i=1; i<5; i++) {
incomingByte = (float)Serial.read();
i = 1.
Serial.read() returns a byte - 8 bits, say 00101001. That example is hex2A, or decimal 42 (32 + 10). If you cast that to a float - the (float) operation - you get a floating number with a value of 42.0 It is represented as 4 bytes, and using the
www.h-schmidt.net/FloatApplet/IEEE754.html website, the values are probably 42280000.
That number, 42.0 is assigned to incomingByte overwriting any previous value of incomingByte.
i = 2.
Serial.read() returns a byte - 8 bits, say 00000001. If you cast that to a float - the (float) operation - you get a floating number with a value of 1.0 It is represented as 4 bytes, and you can work out what they are but it doesn't matter. That number, 1.0 is assigned to incomingByte - IT DOES NOT ADD TO IT.
i=3
much the same
i=4
much the same
i=5
exits loop
It will end up with the (floating) value of the
last of the 4 bytes read.
You need to write the 4 bytes into a byte array and then
use those 4 bytes as a float, as per my code. A cast - which is what the (float) operation is called - will not work. The sketch I wrote a few nights back tries to do that.
Please also answer the question of how the device is connected, because I am interested in how the single serial input pin is used for the device but the serial out goes both to the computer AND the device. That is not a way of connecting hardware that I have met before.
The reason I tried to write the last sketch with a loop, is that you can shake the device up and down, and see if the values are changing. With a one shot, its going to be difficult to alter the acceleration at the exact time you want the reading. At least for testing, try using a loop to read the values repeatedly. Then convert to your one-shot code.