How to Use RGB LED HCāSR04 (RUSā04) Ultrasonic Sensor With Arduino & Visual Programming
In this tutorial, youāll learn how to use the HCāSR04 (RUSā04) ultrasonic distance measuring sensor with a built-in RGB LED and Arduino. Using Visual Programming tool Visuino, weāll create a simple yet effective setup to detect nearby objects and provide color feedback using the onboard LED.
The LED will:
Glow green when the distance is safeTurn red when an object is closer than 5 cmThis setup is perfect for beginners and makes a great first step toward building robot car obstacle avoidance systems or proximity alert devicesāno manual coding required!
Watch the video to see how easy it is with Arduino and visual programming!
Ā
Note: there are several different variants of this sensor, mine has pins (RGB) and {I/O}, so choose the right component in Visuino according to your sensor. You can see available sensors by typing in the search box "RUS-04" or "Ultrasonic"
Add "Compare Analog Range" component, and in the properties window set "Range" > "Max" to 5, this means that the red LED will turn ON if the distance will be below 5cm. Feel free to experiment with the settings.Alternatively you could just use "Compare Analog value" component.
Add "Digital To Color" component and in the properties window set "False Value" to ClGreen and "True Value" to ClRedAdd "Color Multi Source" component, this is optional, you could connect the pins directly, I have added this component so that the project is more organized, in the properties window set "Output pins" to 6

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it and open it in Visuino: https://www.visuino.com
