Hi
One way might be to use the Mapping Function component.
Briefly you enter expected input Min / Max values (e.g. 0-9999) and then the respective output Min / Max values that you want (e.g. 0 - 100). I have probably overcomplicated by trying to explain, but it is a very handy component and very easy to use. This may save you a lot of bother.
Regards
AJ-SR04M Returning 9999 while using the AJ-SR04M Component
-
chipfryer27
- Valued Contributor
- Posts: 1955
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 425 times
- Been thanked: 647 times
-
mnfisher
- Valued Contributor
- Posts: 1878
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 154 times
- Been thanked: 886 times
Re: AJ-SR04M Returning 9999 while using the AJ-SR04M Component
I'm just waiting on some resistors to have a play....
In the UART modes it outputs the length as two bytes - in a 4 byte block (header, datahi, datalo, checksum) - the length is datahi * 256 + datalo
So if we catch the data to an array d[4] it would be d[1] x 256 + d[2]
The result is in mm
The exception is mode 5 (output as a string "12345mm\r\n")...
I've written an outline program - will post the code once tested...
In the UART modes it outputs the length as two bytes - in a 4 byte block (header, datahi, datalo, checksum) - the length is datahi * 256 + datalo
So if we catch the data to an array d[4] it would be d[1] x 256 + d[2]
The result is in mm
The exception is mode 5 (output as a string "12345mm\r\n")...
I've written an outline program - will post the code once tested...
Re: AJ-SR04M Returning 9999 while using the AJ-SR04M Component
Thank you for your help, I intend to use this in the future projects.
Regards,
Pierre
Regards,
Pierre