 # Sending and reading a float array from Processing to Arduino: What is the code?

Hi everyone!

I would like to send frequencies from the simulate pendulum wave from Processing to Arduino!

My project is (just) to make turning motors (servo or stepper motor) at the same frequencies of pendulums

Frequencies are very precises with more than 10 number after the coma and i think it’s impossible to send.

So i have to send the horysontal position of each pendulum ( but 3 will be nice to begin) and recalculate frequencies after.

So for example i would like to send only 3 float from an array of 20 lines.

Here you can see my datas as 0, 1,2 , etc for the first, second, third, etc pendulum and the Xpositions associated

and i added frequencies just to see

My problems. I don’t know the code to send float in array and receve the same float in array in Arduino.

Tanks so much! I bought an Arduino just for that!

Arduino uses 32-bit IEEE Floating Point format. You can expect 6-7 significant figure precision. Note, that’s TOTAL DIGITS of precision, not digits after the decimal point (aka Radix Point).

Why are you casting the float to a byte? Do you think that some how the integral value you send is going to maintain any relationship to the frequency that you are mucking with?

In general, it is better to send strings, and do the conversion from float to string on the Processing end, and from string to float on the Arduino end.

Hi thank you to answer so quickly. I have searched: convert float array in to string array in Processing (google) but i didn't found something easy to do. I am a newbie in Processing but i'm very very motivate to make my project entirely. So if you explain to me, i 'll try to go forward. Thanks you.

If your problem is how to convert a float (array) to a string, in Processing, then the place to ask for help is on the Processing forum, not here.

Will you please clarify the meanings of your post by answering the following simple questions?

1. How many do Arduino you have? Are they UNO, NANO, MEGA, DUE?

2. Do you want to receive(transmit) floating point number by your Arduino? How many digits could be there to the left of the decimal point of your floating point number? How many digits could be there to the right of the decimal point of your floating point number?

Hi. I have only one Arduino UNO. I would like to control servo motors or step motors. I think i will have to check which ones among there are the best to do it and see until which accurately digit i will need. Thank you

I would like to control servo motors or step motors.

Why do you need to send floats to control servo motors or stepper motors? Servo motors can not be positioned to less than one degree resolution using Servo::write(), so sending floats is pointless. If you use Servo::writeMicroseconds() instead, to get more accuracy in the position of the servo, sending floats is still useless, since writeMicroseconds() only accepts ints.

Stepper motors step, one step at a time. You can NOT make a stepper step 1.5 steps, so sending a float containing the number of steps to take is pointless.

PaulS: Stepper motors step, one step at a time. You can NOT make a stepper step 1.5 steps, so sending a float containing the number of steps to take is pointless.

It's not so pointless. You can half-step or microstep a stepper motor. (But it's usually better to use an integer to represent the number of microsteps instead of using a float.)