Digital
Read and set the digital ports of an EZB. A digital port is either on (true, a voltage) or off (false). Set one to turn an LED or a relay on and off; read one to check a button or a switch. The wait command pauses the script until a port changes.
Where to find it: type Digital. in a Python script, or open the ARCx API view of the script editor and expand Digital
Commands
| Command | What it does |
|---|---|
| Digital.Get | Reads a digital port from the EZB to see whether it is on, meaning voltage is detected. |
| Digital.Set | Turns a digital port on or off. |
| Digital.SetRandom | Turns a digital port on or off at random, with an even chance of each. |
| Digital.Toggle | Reads a digital port from the EZB and switches it to the opposite state, so on becomes off and off becomes on. |
| Digital.Wait | Pauses the script until a digital port reads on or off as requested, checking the EZB every 250 ms. |
Details
Digital.Get
Reads a digital port from the EZB to see whether it is on, meaning voltage is detected. Reads as off when the EZB is not connected.
Digital.Get(port)
Digital.Get(port, ezbIndex)
| Value | Type | What it is |
|---|---|---|
port |
int | The digital port, such as d0. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: bool. Whether the port is on.
Digital.Set
Turns a digital port on or off. On outputs 3.3 V on an EZ-B v4 (5 V on a v3) and off connects the port to ground.
Digital.Set(port, value)
Digital.Set(port, value, ezbIndex)
| Value | Type | What it is |
|---|---|---|
port |
int | The digital port, such as d0. |
value |
bool | Whether to turn the port on. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Digital.SetRandom
Turns a digital port on or off at random, with an even chance of each.
Digital.SetRandom(port)
Digital.SetRandom(port, ezbIndex)
| Value | Type | What it is |
|---|---|---|
port |
int | The digital port, such as d0. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: bool. Whether the port was turned on.
Digital.Toggle
Reads a digital port from the EZB and switches it to the opposite state, so on becomes off and off becomes on.
Digital.Toggle(port)
Digital.Toggle(port, ezbIndex)
| Value | Type | What it is |
|---|---|---|
port |
int | The digital port, such as d0. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: bool. Whether the port is now on.
Digital.Wait
Pauses the script until a digital port reads on or off as requested, checking the EZB every 250 ms. Also returns if the script is stopped while waiting.
Digital.Wait(port, valueToWaitFor)
Digital.Wait(port, valueToWaitFor, frequencyMs)
Digital.Wait(port, valueToWaitFor, frequencyMs, ezbIndex)
| Value | Type | What it is |
|---|---|---|
port |
int | The digital port, such as d0. |
valueToWaitFor |
bool | Whether to wait for the port to be on (otherwise waits for off). |
frequencyMs |
int | Optional. How often to check the port, in milliseconds, such as 250. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |