POT (BASIC 7.0)
|Token code:||206/$CE 2/$02|
in BASIC ROM:
|List of all BASIC keywords|
Type: Numeric Function General Programming-Syntax: POT(<numeric-expression>)
The numeric expression must be in range from 1 to 4, referring to the two potentiometer inputs on the two joystick ports. Using any other number generates an error with message ?ILLEGAL QUANTITY ERROR.
The POT command returns the corresponding value of the potentiometer (paddle) position. The returned value is a 9-bit integer number consisting of the eight least-significant bits according to the potentiometer position and the ninth bit which is active if a paddle fire button is pressed (the paddles uses the joystick left and right buttons as fire buttons). The value returned is in range from 0 to 255 without the fire button down, 255 if no paddle is connected, and 256 is added to the value in case the corresponding fire button is pressed.
Examples[edit | edit source]
Display the values of x and y directions on port 2. If the paddle's first fire button is pressed the value will be displayed as joystick direction left (with value 7). The second fire button as right direction with value 3. If both fire buttons are pressed the resulting value is 40.
Checks the condition of the fire button of paddle port 1.
V = POT(1) AND 255
Only the paddle value from port 1 is taken (fire button action is ignored) into variable V.
Gives a permanent tone which is controlled by the position of the first paddle on port 2. The AND function filters the value range in that way that any influence from a pressed fire button is suppressed.