LET P = 6
LET A = IN P
or
LET A = IN 4 + 2
Both of these examples also read the digital value from pin 6 and put it in variable A.
4.7.2 INA function
Reads the analog value of one of the 9 GPIO pins numbered 0 to 8. These pins are capable of
both analog input and digital input. The voltage must be in the range 0 to 3.3V (supply voltage).
The result is a 12-bit number representing the converted voltage to digital (Analog to Digital
Conversion), which is to say, a number in the range 0 to 4095.
If you read a pin numbered greater than 8, the pin number is interpreted modulus 9. For example if
you read pin 12, it is the same as reading pin 3.
Syntax:
INA <GPIO pin number expression>
Example:
LET A = INA 6
Reads the analog value from pin 6 and puts it in variable A.
<GPIO pin number expression> is an expression. Therefore the following examples also work:
LET P = 6
LET A = INA P
or
LET A = INA 4 + 2
Both of these examples also read the analog value from pin 6 and put it in variable A.
4.7.3 RAND function
Returns a pseudo-random number in the range 0 to 2,147,483,647.
Syntax:
RAND
Example:
LET A = RAND
Puts a random number in variable A. The random number seed is updated whenever the GPS
statement executes, from information in the GPS data.
U4B operating manual Rev 1.00
29