Delta_G:
No, it's just odd that you would waste processor resources on software I2C when you already have the hardware I2C running.
What is the problem then ?
Did I miss something up or the could should've worked ?
I don't have good experience and time so I had to go with this code. I want to be sure if I write it for wire it will work just to save time. thank you for the response.
Juraj:
Wire has setClock. try setClock(50000) or setClock(400000) after Wire.begin().
Thanks for the advice.
PaulS:
If it does what you want, yes. If not, no.Break the problem down into pieces. Does the sensor detect a return pulse in a reasonable period of time? Does that time correlate in a meaningful way to distance? If the distance is reasonable, is your calculation of percent correct? If so, does the LED go on when the percent is less than 25? I'm not sure how percent can go over 100, so I can understand why the LED never goes off. You don't pour coffee until your cup is 100% full, do you? Why are you pumping the tank 100% full?
I Just want to make sure that I translated what I wanted correctly. Sometimes the reading goes above 100%. I don't know why. The values I keep changing them for testing. I want to stop the pump when it reaches the maximum which is 100%. I'm using constraint function so it's not really 1:1 scale to the tank. the sensor can't read below 20 cm.
I don't have a fixed level. My point for the project is showcasing it can start/stop the pump in practice. After that, we can set them as appropriate.