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, Im still doing some testing, but could you put back the LED for manual mode on D21 of your Robust EZB_D22 script? It always throws me off when it not on.
Perfect - I added D21 LED control to the robust EZB_D22 monitor so the LED turns ON when the robot is in manual mode and OFF when in Automatic mode. The script uses the existing ezbIndex and only writes D21 when the mode actually changes (to avoid repeated writes). It also sets the LED after reconnect settle/read so it matches the announced mode.
Paste this into your Script skill (JavaScript tab), save and Start it. If your Script skill has a different title, update skillTitle. If you want the LED behavior reversed (ON for Automatic), tell me and I’ll flip it.
Updated script (JavaScript)
Quick testing tips
Note about the LED logic
Next
Tell me which LED polarity or blink preference you want, and I’ll provide that tweak.
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.
Yes, I would like the LED on D21 to blink briefly when mode changes, and add the log file as you suggested.
Great - I added the blink-on-change behavior and a timestamped log file to the robust EZB_D22 monitor. Paste the script into a Script robot skill (JavaScript tab), save and Start it. The script will:
Important: put this code in the Script skill JavaScript tab (not EZ-Script). Update file path or ezbIndex if needed. If Windows permissions block file writes, change the logFile path to a writable folder (see notes below).
Script - paste into your Script skill JavaScript tab
Notes and troubleshooting
Follow-up
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.