Skip to main content

AD

Syntax

AD (  expression ) 

Description --- Not available on ARMstamp

 

AD will return 0..  that corresponds to the voltage on the pin corresponding to expression. The value returned will be between 0 and ... 65472, with the top 10 bits being significant.  (bits 5..0 will be 0). 0 would be read for 0V and 65472 for 3.3V.

An analog conversion on pin expression  is performed.  This process takes less than 6 usec.

Dual Use AD pins

 

On reset or power up the AD pins are configured as AD inputs.  To change those to digital IOs, the user must individually specify a control direction using INPUT x, OUTPUT x, DIR(x), or IO(x) commands.  After that they will remain digital IOs until the next reset or power up.

Example

voltage = AD

(0) ' this will read the voltage on pin 0

Differences from other BASICs

  • no equivalent in Visual BASIC
  • no equivalent in PBASIC

See also