OK NO HELP I WONDER WHY THIS ISSDDADSSDASDC ANDDNOYING WRDJDLWEAMFDADWDD
Why do you need to store all readings?
Don't you just want to keep track of the minimum value and the angle at which they occurred?
yes i do but im not sure how to do it without storing the values since i need to store and convert from string to float to read and compare them
String incomingByte = Serial.readString();
IRvalue[m] = incomingByte.toFloat();
1) incomingByte is a pretty dreadful name for this - it's not really a "byte" - it's a variable number of bytes.
2) Why do you need it inside the for() loop anyway. You just need one instance of incomingByte that you keep re-using. Once you have taken the float out of it simply clear it for next time ( incomingByte.clear() ), actually create it outside the for() loop.
Like Kartman I wonder why you store all the floats then look for min/max later ? You can do all that as you go along receiving the things. Same goes for testing below 25. Also as a reader of this code I have no idea what the significance of the value 25 us anyway. You might want to add a comment to tell the reader why that value and what units it is in perhaps?
SOLVED THANK BROTHER FROM THY OTHER MOTHER :)(dmeifnd
Is there any better way of reading serial numbers quickly?
Why are you using float????? That seems a bit ridiculous or poor planning. Pay attention.
When in the dark remember-the future looks brighter than ever. I look forward to being able to predict the future!
and serial.readstrings timeout function
You can reduce this with: https://www.arduino.cc/reference.... The timeout is only really useful if it's a human typing the characters. Or use: https://www.arduino.cc/reference...
Arduino String objects are trainer wheels. Horribly inefficient and memory hungry, but useful until you learn how do things 'properly' with chars and C-style char arrays.
Arduino String objects are trainer wheels.
they seem to be (somewhat) different from standard C++ strings: https://www.avrfreaks.net/commen... ?
There is some attempt to minimise memory reallocation and fragmentation, with a method to reserve a buffer: https://www.arduino.cc/reference...
Of course, it's easy to take potshots at Arduino and we should remember the original purpose and target audience for the project, regardless of how that has changed over the years.
I am a bit puzzled about what the OP means by "simulated robot sensor". Is the sensor simulated? Is the robot simulated? From the postings, it sound like there is real hardware, not simulated.
Until Black Lives Matter, we do not have "All Lives Matter"!
© 2020 Microchip Technology Inc.