
PRO
smiller29
USA
Asked
Could you please provide the command for the Ultrasonic Distance Sensor within the EZ-B protocol that is not yet included in the current protocol documentation?
Related Hardware Arduino Genuino Uno
Related Control
Ultrasonic Distance
Below is the answer that should work with your Arduino Genuino Uno running EZB Firmware. (Note that although this command isn’t yet in the publicly available EZB protocol documentation, it’s used internally by our Ultrasonic Distance skill.)
The Undocumented Ultrasonic "Ping" Command
When the Ultrasonic Distance skill is active, it uses an internal command-commonly referred to as the "GetPing" command-to request a new measurement from the ultrasonic sensor. In custom robot skills (or within your own JavaScript code) you can invoke this functionality using:
GetPing(<port>)
where <port> is the digital port (for example, d7) to which your sensor’s trigger/echo line is connected. When called, EZB Firmware will:
Send a ping on that port
Return a distance value in the range 0-255 (an arbitrary value that you can scale using a multiplier)
Example in JavaScript
Below is an example script using JavaScript in ARC (remember that you should reference the port constant without quotes):
Things to Note
The returned value is not in a fixed unit (cm or inches) until you apply your own multiplier.
This command is called automatically by ARC’s Ultrasonic Distance skill (when you have the "PAUSE" checkbox unchecked or when calling GetPing() in your script) so you rarely need to call it manually unless you’re creating a custom behavior.
Ensure you use the proper port constant (like d7) without quotes.
Next Steps
If you’d like to expand your robot’s functionality beyond the provided skill, consider creating additional skills. You can find helpful instructions on creating your own custom robot skills here:
Create Your Own Robot Skill
Does this answer the command request for your project? Let me know if you need additional details or further assistance!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.