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!

Oh cool little unit. Make sure you have a common gnd between everything.
Nice - thanks for the detailed hardware info. Yes, that Pololu multiplexer is a clean solution and will avoid the direct "two outputs fighting" problem if wired and used correctly. A few short confirmations and then a ready-to-use JavaScript snippet you can paste into your monitor script (and suggestions for where to put it).
Key points / confirmations
Why Servo.release() is useful here
Recommended JavaScript monitor to detect D22 and act on changes
Paste-ready JavaScript (Script skill JavaScript tab)
Where to put it and startup
Notes on EZScript vs JavaScript
Wiring checklist (quick)
Extra suggestions
Anything else you want me to add or change (e.g., invert the D22 logic, add file logging, integrate into reconnect script)?
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.
oh cool, I will try this new D22 Mode Monitor script. Also like the idea of merging the scripts you suggested and will try that as another option for me.
I also went thru all scripts and corrected any syntax errors on my part. Also made sure these scripts were in the right script skill (javascript or ezscript) this made a major difference with way less disconnect issues before.
Nice work - glad fixing the editor locations and syntax cleaned up a lot of the problems. Good sign.
Below I’ve provided a merged JavaScript Script skill that combines:
Before you paste/run
Merged Script (JavaScript)
How to autostart this merged Script
Important notes and follow-ups
Anything you want changed now? If you post:
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
I have tried both new scripts. They work but noticed a couple of things:
First, I dont see the LED on D21 I believe, ever lite up when in manual mode anymore.
Second, When I first connect, it use to announce which mode the D22 was in. Also, a couple of times, it would disconnect after I make a switch,the reconnect, and fail to announce which mode it was last in. but would announce it after I flip switch again (but no more disconnects).
Here is one error message I did get while switching between automatic/manal Mode: Manual Monday, December 22, 2025 9:23:15 PM - Mode change -> AUTOMATIC detected (D22=1). Running HB25 Init and resuming automatic control. Monday, December 22, 2025 9:23:18 PM - Mode change -> manual detected (D22=0). Releasing servos and stopping automatic movement. Monday, December 22, 2025 9:23:19 PM - EZB index 0 not connected. Attempting to connect. Done (00:00:12.8651506)
Thanks - good troubleshooting notes. The behavior you described fits a few small issues we can fix in software, plus a hardware check I’ll remind you about.
Summary of what I changed and why
Please check wiring/ground (hardware reminder)
Updated Script (paste into a Script skill JavaScript tab)
What I changed (concise)
Next steps / suggestions
Want me to invert LED logic, change the LED-on-mode (Manual vs Automatic), or move the log file location? Also say if you want this script split back into two skills (Reconnect + Mode Monitor) instead of merged.
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.
ok, so the program is somewhat working, I think I know why.
In the connection skill, I have this: (which is an EZBscript)
controlCommand("EZB Reconnect Monitor ", "ScriptStart") controlCommand("HB25 Init", "ScriptStartWait") sleep(500) #wait a bit, or remove if you don't need a delay controlCommand("EZB_D22_ConnMerge", "ScriptStart")
As you can see, on the first line is the EZB reconnector monitor script controlcommand. Is this script still needed? Isn't this script now part of the merged EZ Reconnect + D22 Monitor script above? Will this also explain why when I want to disconnect from EZB, the program immediately reconnects. So I have wait a couple seconds to click disconnect again and then it stays disconnected.
Finally, the LED does in fact lite up in manual more as I want, but is not blinking, lets make it blink againc
Yes - that explains the behavior and is an easy fix. Short answers first, then exact steps and a paste-ready JavaScript update.
Summary
What to change now (step-by-step)
Edit Connection -> Settings -> Connection Established Scripts (this area takes one-line ControlCommand() commands)
If you want a way to temporarily disable automatic reconnects (so clicking Disconnect stays disconnected), add a global flag and the guard to the merged script. I recommend this so you can control reconnect behavior from a button or quick script.
Updated merged script (adds reconnect guard + blinking LED)
Paste-ready JavaScript (replace values at top as needed)
How to use the $AllowAutoReconnect guard
Next steps and checks
Would you like me to:
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.