Led on and off depending on water height from Hsiang Ju Hung on Vimeo.
I modified my code and finally got it work!
IR sensor make Led turn on based on height of water
I have not used linearizing formula yet. Just make the old one do only one thing:
if(val < 235){
digitalWrite(led,255);
}
else{
digitalWrite(led,0);
}
I used a water filter container to test again, which is 0 cm to 22 cm tall.
And I set if the value is bigger less then certain number, make the led turn on.
Here is the simulation of controlling recorder, which also works.
simulation of controlling recorder by IR sensor from Hsiang Ju Hung on Vimeo.
But when I plugged the connector from Arduino to Play pin on my recorder, it did not make any sound.
I checked my recorder. Everthing worked fine. I can press the button to play, record, and forward the sound.
Problem#1: I cannot control recorder with arduino, which has worked before.Don't know what's wrong with it... maybe need to build a new recorder to try again.
Problem#2: The value keeps changing every time when I put ir sensor onto the surface of water. Sometimes the same water height gives very different values. Basically, value goes from 270 to 230 when water goes from 14 cm to 22 cm. It maybe give you 270 at 14 cm this time, but next time it gives you 250 at 14 cm. It's very hard to control the range. I have to modify the range each time according to the value I got at 14 cm. I am wondering if there is anyway I can take the beginning value as valueA and set if val- valueA > a range then turn off the led. I'm going to modify the code.
Oh, and I got the giant rubber duck. It's bigger than I imagined...
The plan is to cut a hole at the bottom and put circuit inside once I get it work well.
I found the reason for different value output from ir sensor!!! Those bubbles in front of either emitter or receiver made the reading unstable....
Comments