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!

Here is my setup, The EZB is currently powered up separately via a wall power supply, supplies 7.5V. The two HB25 are powerd by a 12V 10A SLA battery. The two HB25 are connected to D12 and D13. I Have a small LED on D21 and R/C controls the Pololu Data switch (via channel 5 of the receiver) on D22. There are no other connections on the EZB at this time.
I first powered up everything without the motors powered and watched the status of the script run, I could flip r/c switch back and forth, did not have a disconnect. Then powered up motors, watch the script run again and so far seems smooth. I found that if you do flip r/ swich to fast, it does confuse the script and cause the disconnect.
Also,when the HB25 motor controllers are first power, they need a moment to init. I always have to use the following script (Ezscript)that someone created long time ago.
#ControlCommand( "SoundBoard v4", Track_0 ) #ControlCommand( "Speech Recognition",PAUSEMS,1000) $x = getDigital(D12) $x = getDigital(D13) if ($x = 0) sleep(5) # wait for 5mS for HB25 to initialize servo(d12, 104) # HB25 connected to D0 set for stop value Servo(d13, 104) # HB25 Connected to D1 set for stop value sleep(20) # wait for 20mS endif
This script always works or the HB25
I also will be changing out this laptop,s battery, Discoverd it loses charge too quick (used laptop). works better when plugged in. But yes, your diag script seems to work ok at the moment.
Great details - thank you. Your hardware setup looks correct (EZ-B powered independently, HB25 motors on their own 12 V battery). That already avoids a common brown-out issue. A few likely causes remain and I’ve addressed each with concrete fixes and a safer JavaScript script you can paste into the Script skill.
Key points / checks before running the JS
Paste this into the Script skill JavaScript tab and Start:
Why this should fix your disconnects
Extra recommendations and troubleshooting steps
Conversion of your old EZScript init (the snippet you posted) Your EZScript:
Converted to the JS init function above (initializeHB25). It waits 200 ms and sets neutral twice so the HB25 has time to initialize. You can reduce the waits if you prefer (I used slightly larger waits to be safer).
Follow ups
If you’d like, I can also give a minimal version with no audio or LED for stress-testing, or a variant with a shorter or longer debounce time - tell me how fast your RC switch bounces (millisecond estimate) and I’ll tune the debounce.
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.
So I tried both new scripts:
The revisedHB25 script did not work ,see error below: Start Error on line 3: Missing binary operator: True [?] sleep(5) Done (00:00:00.0280197)
The other script worked fine. Did rapid switching, seems ok. Made sure I have common ground, also good.
Also had another idea, would like the two scripts to start up and be running right after establish connection with the EZB. I tried to add this myself and followed the cheat sheet, but nothing happened. Is there some new way of doing this now?
Thanks - good detective work. That error message (Missing binary operator: True) is exactly what happens when JavaScript is pasted into the EZScript editor (or when an expression/boolean syntax from JS is interpreted by the EZScript parser). You only got that error on the HB25 script because that one I gave is JavaScript and it was probably pasted into the EZScript tab.
Two things to fix and set up:
Recommended: Configure the Connection skill to run scripts on connect
Alternate (explicit controlCommand) - use this if you prefer to add the start commands yourself:
Master Init approach (often simplest to manage)
Correct JavaScript for the HB25 + D22 startup (paste into the JavaScript tab)
Quick checklist to get auto-start working
If you want me to make a tiny Init script that starts two existing scripts for you, tell me:
Finally - follow up questions
If you paste the exact Script skill names you use I’ll give the exact ControlCommand lines and a short Init script you can paste into the Connection setting or into a single Script skill.
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 fixed the HB25 script issue, I did in fact paste your JS into it as a ezscript. But it comes back with :
Start Execution Error Line 1 Col 0 - getDigital is not defined Done (00:00:00.0144784)
The other script works . But I noticed the audio is coming out of pc, I thought it was coming out of EZB before?
Also, I corrected my init script (had also pasted in ezscipt instead of JS).
I have more scripts to add, but want to fix these issues first.
Perfect - you found the cause. The error messages you saw came from mixing EZ-Script functions with JavaScript. getDigital(...) is an EZ-Script function and does not exist in the JavaScript runtime. In ARC JavaScript the equivalent is Digital.get(d22) which returns a boolean (true = HIGH, false = LOW).
Below I’ll cover the quick mappings, how to choose PC vs EZB audio, how to autostart scripts, and give a corrected, ready-to-paste JavaScript version that replaces the old EZ-Script init + D22 monitor. Paste this into the Script skill JavaScript tab (not the EZScript tab).
Quick mapping (EZ-Script JavaScript)
PC audio vs EZB audio
Use EZB audio if you need the sound on the robot. Use PC audio to reduce traffic/load on the EZB (recommended for stability).
Autostarting scripts when EZB connects
Corrected JavaScript (paste into Script JavaScript tab)
What likely caused your earlier errors
If you want EZB audio
Autostart reminder
Next steps / Offer
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.
Athena
I tried the new JS you created. Works fine but ran into two issues:
first issue, the HB25 script gave me this issue:
Start Execution Error Line 1 Col 0 - getDigital is not defined Done (00:00:00.0116977)
This was working before
second issue, I wanted to change audio output from PC to EZB, followed your note in the script, var useEZBAudio = true; // set true if you want EZB speaker (Audio.sayEZB, soundNote with ezbIndex)
but got this error instead: Mode: manual (D22 LOW) Execution Error Line 33 Col 4 - No public methods with the specified arguments were found. Done (00:00:00.6908732)
was I suppose to edit elsewhere in the script?
Thanks - good details. Both errors are common and easy to fix. Summary first, then a corrected JavaScript you can paste (into the Script skill JavaScript tab), and short troubleshooting steps so this won’t repeat.
Short summary of causes
What to do now (quick checklist)
Corrected JavaScript (ready to paste into Script JavaScript tab)
Why this should fix both problems
If you still see the getDigital error after pasting the code
If you want, I can
Quick question so I can help further
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.