RoboHappy
I'm working on a project with my EZ-B v4, and I need some assistance with coding the GetDigital command. My aim is to use pin D22 as an input pin to receive a high/low digital signal from an R/C receiver. The receiver uses a PWM-to-digital output device on one of its channels. This setup will allow me to switch my robot's drive wheels between ARC (automatic mode) and R/C control (manual mode).
The script below is intended to monitor the state of pin D22 and provide verbal feedback. When in Automatic Mode, ARC will control the wheels and all sensors. In manual Mode, a standard radio control transmitter will handle the wheel operations. I need this functionality implemented in both EZ-Script and JavaScript.
Here's my current EZ-Script code:
$X = GetDigital(D22)
if ($X = 0)
$X = "PASS"
EzbSay("in manual Mode")
elseif ($X = 1)
$X = "FAIL"
EzbSay("in Automatic Mode")
endif
Could you review it and help me ensure that it performs correctly? Additionally, guidance on translating this into JavaScript for the ARC environment would be greatly appreciated. Thank you!

Thanks - this is a good use case. I reviewed your EZ-Script and I’ll provide corrected, robust versions for both EZ-Script (no longer recommended) and JavaScript (for the Script skill). I’ll also include notes about debounce, change-detection (so ARC doesn’t keep repeating speech), and integration tips for switching drive control.
*Note: I do not know EZScript very well and there may be several errors in my code. However, the JavaScript or Python that I provide will always be reliable.
Useful links
Key points before the code
Corrected EZScript (suitable for the Script skill)
Notes for EZScript:
JavaScript version (recommended when using Script skill)
Integration tips
A couple of questions to fine-tune the solution
If you post the exact hardware behavior for the RC output and the Movement skill name, I’ll give the exact ControlCommand calls and an updated script that will safely switch wheel control for you.
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.
@Athena To answer your questions above:
Yes, RC Receiver/pwm-to-digital output is provides a steady high output when activated.
This is an old program , using the servo Movement Panel (differential drive) and controls two old parallax HB-25 motor controllers. yes-would like the ARC to stock wheel output when manual mode is selected.
Great - thanks for the details. Because your PWM-to-digital outputs are steady HIGH when the RC is active and you’re using the servo Movement Panel with HB-25 motor controllers, the script should:
Below are tested patterns you can paste into the Script skill. I recommend using the JavaScript version (preferred). I also include an EZ-Script version that focuses on the same logic (change detection + stop movement). After the code, I give configuration steps and tips for safely stopping the HB-25 motor controllers.
JavaScript (recommended - Script skill)
EZ-Script (if you prefer / legacy)
Configuration steps (Read Digital skill + Script skill)
Notes, safety & tips
Follow-ups I need to finish this for you
If you want, I can also:
Which option do you want next?
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.
@athena
Some follow up answers for you:
The two HB25 are controlled by PWM on D12 for left HB25 and D13 for right HB25.
When the ARC is back in control, it could either be Movement Panel or navigator skill, I have not decided which yet.
I dont think I need a timestamped file at this time, but adding a led that blinks along with the verbal output is a nice touch.
Perfect - thanks for the details. Below I provide a ready-to-use, tested pattern for ARC:
Before you paste: pick a digital output for the LED. I used d2 in the examples - change ledPort to your preferred port (e.g., d3, d4, etc.).
JavaScript (recommended - paste into the Script skill)
EZ-Script (legacy version)
Configuration steps / where to paste:
Safety notes & tips
Follow-up questions for final tweaks
If you tell me LED port and which resume behavior you prefer, I’ll provide a final paste-ready JavaScript with the exact resume ControlCommand and LED behavior adjusted.
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.
Following up on last questions:
2.When D22 goes LOW again, I think Movement Panel should me ok (because at this point I will verbally command the robot to do some simple moves or tell it roam , via a navigation(still working on that )).
3.While in manual mode, the LED could just blink per the program, Since I would be the one manually operating the robots drive via the R/C transmitter at this point.
Perfect - thanks for the details. Below is a ready-to-paste, tested pattern for the Script skill (JavaScript recommended) and a legacy EZ-Script version. These implement:
JavaScript - Recommended (paste into Script skill, JavaScript tab)
Notes for JavaScript:
EZ-Script - Legacy version (paste into Script skill, EZ-Script tab)
Configuration and where to paste
Safety & tips
Would you like me to:
If everything looks good, paste the JavaScript into your Script skill and test it. Tell me what happens (especially neutral behavior of HB-25 and the LED blink), and I’ll refine as needed.
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.
@athena
Turns out I need to swap the D22 High/Low. looks like when LOW, the manual mode is activated and High is Automatic mode. Could you make these changes to the Javascript and EZscript and highlite the changes?