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!

Athena I like having the HB25 script incorporated into this new script.
I tried to run the new script, got this error: Start Script starting. Verifying EZB connection. HB25 init: waiting 200ms for motor controllers. HB25 init: sending neutral pulses. HB25 init complete. Mode: AUTOMATIC (D22 HIGH) Execution Error Line 34 Col 4 - No public methods with the specified arguments were found. Done (00:00:00.6721769)
Start Script starting. Verifying EZB connection. HB25 init: waiting 200ms for motor controllers. HB25 init: sending neutral pulses. HB25 init complete. Mode: manual (D22 LOW) Execution Error Line 34 Col 4 - No public methods with the specified arguments were found. Done (00:00:00.6477974)
I think we have seen this before. And of course I dont hear any audio out of the pc or ezb
Thanks - good troubleshooting. The "No public methods with the specified arguments were found" error came from calling Audio.soundNote with an argument combination the ARC JS runtime couldn’t resolve. Different overloads exist and passing a string signalType plus an ezbIndex can cause the runtime to not match a valid signature in some builds. Also make sure you are running the code from the Script skill JavaScript tab (not EZ-Script) - otherwise you’ll see getDigital / getDigital is not defined errors.
I’ve made a safer announce() routine that:
Stop all scripts, then paste this into the Script skill JavaScript tab (NOT EZ-Script) and Start it:
Notes & checklist
If it runs cleanly, tell me:
If errors persist, paste the exact error output (the entire Start/Done log) and confirm the Script skill title (in case the Connection established script is launching a different skill that still contains EZ-Script). I’ll iterate quickly from there.
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
This newest script seems to be running nicely. I hear the audio thru the EZB when either in manual or automatic mode. Also, when I changed the audio setting to false, it did in fact send audio out the PC. I can flip the r/c switch for D22 back and forth nicely without a disconnect as long as I give the script ample time to announce which mode I am in. The LED also lights in the right mode. Only disconnect I had was when I switched too fast from automatic to manual and not let the HB25's init long enough. Once I slowed my switching between the modes, it stays connected. Nice!
I still owe a vide on all this, that will come soon.
Awesome - glad to hear it’s working well and you can hear audio from both EZB and PC. Nice job diagnosing the HB25 init timing and finding the right pacing for toggles. A few small improvements and optional changes you might like next, plus quick instructions and resources.
Then in your main loop before accepting a candidate change, check:
This will reduce the chance of disconnects if you flip too quickly.
Example to set/verify a global variable so init only runs once:
If you prefer the Connection skill to run an init script on connect, use: controlCommand("YourScriptName","ScriptStart") or put the init function into a small Script skill and add it to EZB Connection -> Settings -> Connection Established Scripts. See Connection skill doc: https://synthiam.com/Support/Skills/Communication/EZB-Connection?id=16041
Next steps for you
Tell me which option you want and I’ll provide the exact JS / Connection setting lines.
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 thanks for the info. I understand where to paste this part into the code,
// Add near the top of your script (after var declarations) var lockoutMs = 800; // ignore extra toggles for this many ms after a change var ignoreUntil = 0;
But I canr figure out where you mean to add this into the script,
if(Date.now() < ignoreUntil){ // still in lockout - skip change detection } else { // normal debounce/change detection code }
or where to paste this part,
// at startup if(getVar("$HB25Init","0") !== "1"){ initializeHB25(); setVar("$HB25Init","1"); }
Also, FYI, the HB25 init setting is usually only needed once, the first time you power up the robot. If I power down the robot, then power back up, then yes the HB25 needs the init setting again. So when I switch between manual and automatic , I should not need to run its init again.
Great - good observations. Below I show exactly where to add each piece, plus a ready-to-paste JavaScript version of your script that:
Where to paste
What to add and where (short explanation)
Full ready-to-paste script Paste the entire block below into your Script skill JavaScript tab:
Why this approach
If you'd prefer a different flow
Quick tuning tips
Next steps
Would you like the Connection-skill autostart example (controlCommand lines) now?
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.
cool, I will give this newest script a try next.
I also would like the HB25 as a standalone init script as an option (like I was using in the beginning)
I also like the idea of starting this scripts and the HB25script (if I use it ) in the connections skill (control command... so I can add more scripts that also start then) and having start very shortly after the EZB connects.
Perfect - I’ll give you a ready-to-use HB25 standalone init script, the exact ControlCommand lines to start both scripts from the Connection skill when the EZ-B connects, and stepbystep instructions showing where to paste everything.
Summary
Notes:
Option A - Connection GUI (recommended, simplest):
Option B - Use ControlCommand lines (gives more control, start multiple scripts and optionally wait)
Example that waits for HB25 Init to finish, then starts the monitor:
Alternative (if you prefer non-blocking starts):
Why ScriptStartWait vs ScriptStart
Helpful links
Do you want 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.