imranahmed
Advanced Member level 3
- Joined
- Dec 4, 2011
- Messages
- 817
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Karachi,Pakistan
- Activity points
- 6,492
pourcent = map( ultrasonic, 1, 13, 100, 10);
Not properly working this code it shows different values I want to display by gap of 5% 100%,95%,90%,85%..........10%C:pourcent = map( ultrasonic, 1, 13, 100, 10);
Hi,
how does the digital readings look like. Please list a couple of digital values and their corresponding distance.
BR
Tank size is programmed with different sizes selected in menu from 1 to 13 feet.Hi,
how does the digital readings look like. Please list a couple of digital values and their corresponding distance.
BR
If I have tank of 7 feet then I will set tank size 7ft then readings should be display according tank size i,e 7ft.
Yes exactly 100% rightHi,
I'm curious if the readings are linear (I asume so). If so, someone can solve this problem easily by an equation. The question is, do the readings (digital values) increase or decrease with an increasing distance? Is the relation direct or indirect proportional?
So if it possible please post some digital values and their corresponding distance, as it seems you have the measurement results. With this values we are able to provide you an appropriate equation, and with the values we are able to check the suggested solution before posting.
So you also want to adjust the maximum depth of the tank e.g. one tank ranges from 1 ft (100 %) to 13 ft (10 %) and an other one from 1 ft (100 %) to e.g. 7 ft (10 %). Am I right?
BR
Digital values in percentage are indirect proportional to distance because water tank full means 100% and distance is minimum because ultrasonic sensor is attached upside down in the top of the tank.Hi,
I'm curious if the readings are linear (I asume so). If so, someone can solve this problem easily by an equation. The question is, do the readings (digital values) increase or decrease with an increasing distance? Is the relation direct or indirect proportional?
So if it possible please post some digital values and their corresponding distance, as it seems you have the measurement results. With this values we are able to provide you an appropriate equation, and with the values we are able to check the suggested solution before posting.
So you also want to adjust the maximum depth of the tank e.g. one tank ranges from 1 ft (100 %) to 13 ft (10 %) and an other one from 1 ft (100 %) to e.g. 7 ft (10 %). Am I right?
BR
I have ultrasonic sensor values in feet from 1 ft to 13 ft.
I am not using Arduino function but intent to make a function to get result in percentage.Hi,
I assume you have the DIGITAL values e.g. 1 m = 512, 2 m = 384 m, 3 m = 256, 4 m = 128 .... (just an example). It's much easier to provide a solution with actual measurement results instead of guessing and assuming things.
Or are you using an arduino function which already provides percentage as a result?
Br
distanceFeet = map(distanceValue, 1, 13, 100, 10);Hi,
I assume you have the DIGITAL values e.g. 1 m = 512, 2 m = 384 m, 3 m = 256, 4 m = 128 .... (just an example). It's much easier to provide a solution with actual measurement results instead of guessing and assuming things.
Or are you using an arduino function which already provides percentage as a result?
Br
--- Updated ---
How have you implemented the map() function?
Ok I will try it.Hi,
so if you are only interested in a 5 % ranges starting from 10 % (13 ft), you can use switch/case statement to map your readings to the desired percentage (which should be displayed) see [1].
[1]https://www.arduino.cc/reference/en/language/structure/control-structure/switchcase/
BR
Looks like below?To obtain increments of 5, scale your data values to occupy a range of 1 to 20, truncate the fractional portion, then multiply the remaining integer by 5.
t = pulseIn(echo, HIGH);
// Calculating distance
h = t / 58;
h = h - 6 ; // offset correction
h = 20 - h; // water height, 0 - 50 cm
hp = 5 * h; // distance in %, 0-100 %
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?