Text Overlay icon Text Overlay — Overlay a variable on a processed camera image at X/Y coordinates; name the variable and attach to a specific or any available camera Try it →
 

ADC

Read the analog (ADC) ports of an EZB. An analog port measures a voltage, such as from a potentiometer, a light sensor or a battery divider, as a number from 0 (0 volts) to 255 (5 volts), or 0 to 4095 with the 12 bit commands. The wait commands pause the script until a reading crosses a value.

Where to find it: type ADC. in a JavaScript script, or open the ARCx API view of the script editor and expand ADC


Commands

Command What it does
ADC.get Reads an ADC port on the first EZB as an 8 bit value from 0 (0 volts) to 255 (5 volts).
ADC.get12Bit Reads an ADC port on the first EZB as a 12 bit value from 0 (0 volts) to 4095 (5 volts).
ADC.waitForBetween Waits until an ADC port on the first EZB reads between low and high (inclusive, 0 to 255), checking every 100 ms.
ADC.waitForEquals Waits until an ADC port on the first EZB reads exactly the given value (0 to 255), checking every 100 ms.
ADC.waitForHigher Waits until an ADC port on the first EZB reads above the given value (0 to 255), checking every 100 ms.
ADC.waitForLower Waits until an ADC port on the first EZB reads below the given value (0 to 255), checking every 100 ms.

Details

ADC.get

Reads an ADC port on the first EZB as an 8 bit value from 0 (0 volts) to 255 (5 volts). Boards with higher resolution ADCs are scaled down to this range.

ADC.get(port)
ADC.get(port, ezbIndex)
Value Type What it is
port number The ADC port, such as adc0.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number. The reading, 0 to 255.

ADC.get12Bit

Reads an ADC port on the first EZB as a 12 bit value from 0 (0 volts) to 4095 (5 volts). Boards with 8 or 10 bit ADCs are scaled up, so the value moves in steps of 16 or 4.

ADC.get12Bit(port)
ADC.get12Bit(port, ezbIndex)
Value Type What it is
port number The ADC port, such as adc0.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number. The reading, 0 to 4095.

ADC.waitForBetween

Waits until an ADC port on the first EZB reads between low and high (inclusive, 0 to 255), checking every 100 ms. The script pauses until then or until it is stopped.

ADC.waitForBetween(port, low, high)
ADC.waitForBetween(port, low, high, frequencyMs)
ADC.waitForBetween(port, low, high, frequencyMs, ezbIndex)
Value Type What it is
port number The ADC port, such as adc0.
low number The lowest acceptable reading, 0 to 255.
high number The highest acceptable reading, 0 to 255.
frequencyMs number Optional. How often to check the port, in milliseconds.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number. The reading that matched, or -1 if the script was stopped first.

ADC.waitForEquals

Waits until an ADC port on the first EZB reads exactly the given value (0 to 255), checking every 100 ms. The script pauses until then or until it is stopped.

ADC.waitForEquals(port, value)
ADC.waitForEquals(port, value, frequencyMs)
ADC.waitForEquals(port, value, frequencyMs, ezbIndex)
Value Type What it is
port number The ADC port, such as adc0.
value number The reading to wait for, 0 to 255.
frequencyMs number Optional. How often to check the port, in milliseconds.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number. The reading that matched, or -1 if the script was stopped first.

ADC.waitForHigher

Waits until an ADC port on the first EZB reads above the given value (0 to 255), checking every 100 ms. The script pauses until then or until it is stopped.

ADC.waitForHigher(port, value)
ADC.waitForHigher(port, value, frequencyMs)
ADC.waitForHigher(port, value, frequencyMs, ezbIndex)
Value Type What it is
port number The ADC port, such as adc0.
value number The reading must rise above this, 0 to 255.
frequencyMs number Optional. How often to check the port, in milliseconds.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number. The reading that matched, or -1 if the script was stopped first.

ADC.waitForLower

Waits until an ADC port on the first EZB reads below the given value (0 to 255), checking every 100 ms. The script pauses until then or until it is stopped.

ADC.waitForLower(port, value)
ADC.waitForLower(port, value, frequencyMs)
ADC.waitForLower(port, value, frequencyMs, ezbIndex)
Value Type What it is
port number The ADC port, such as adc0.
value number The reading must drop below this, 0 to 255.
frequencyMs number Optional. How often to check the port, in milliseconds.
ezbIndex number Optional. Which EZB to use, 0 being the first one.

Gives back: number. The reading that matched, or -1 if the script was stopped first.