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 Python 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 |
int | The ADC port, such as adc0. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: int. 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 |
int | The ADC port, such as adc0. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: int. 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 |
int | The ADC port, such as adc0. |
low |
int | The lowest acceptable reading, 0 to 255. |
high |
int | The highest acceptable reading, 0 to 255. |
frequencyMs |
int | Optional. How often to check the port, in milliseconds. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: int. 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 |
int | The ADC port, such as adc0. |
value |
int | The reading to wait for, 0 to 255. |
frequencyMs |
int | Optional. How often to check the port, in milliseconds. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: int. 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 |
int | The ADC port, such as adc0. |
value |
int | The reading must rise above this, 0 to 255. |
frequencyMs |
int | Optional. How often to check the port, in milliseconds. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: int. 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 |
int | The ADC port, such as adc0. |
value |
int | The reading must drop below this, 0 to 255. |
frequencyMs |
int | Optional. How often to check the port, in milliseconds. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: int. The reading that matched, or -1 if the script was stopped first.