I would like to know how to develop a code using ultrasonic sensors to brighten a led light which is already on.
Based on what criteria?
(please post your responses here, not using the "report to moderator" control)
The light would already be on in the Dim state. However, when an abject is in range of the ultrasonic sensor the light will be brightened and will stay bright if the object is still in range, once out of range the light remains bright for sort period of time then goes back to dim.
setBrightness (ledPin, objectInRange () ? highBrightness : lowBrightness);
You just need to fill-in the details.
(Note: setBrightness may reduce to analogWrite)
I would like to use the mentioned system to control street lamp for a roadway. The ultra sonic sensor that will used is HC-SR04.
I not sure how to write the code.
What do you need help with?
Do you know how to dim (or brighten) an LED?
Do you know how to read the ultrasonic sensor?
Once you can read the sensor and adjust the brightness you can "connect" the input & output with an if-statement or a map() function, etc.
Have you worked through any of the provided examples?
I'd like to know how to write the code. I have check and found examples but they used different sensors.
There is code for the SR04 for sure.
I would like an example of a code that does what my project requires.
See reply #4.
Or do you want the whole code writing for you?
I would like to learn how to do it. But if someone can write the code that would help is understanding how to do it. I don't have issues wiring the circuit just the code.
DRX:
I would like to learn how to do it. But if someone can write the code that would help is understanding how to do it. I don't have issues wiring the circuit just the code.
a very helpfull link for you providing allmost all the code.
Thanks.