Skip to content

BASIC Functions

Mario Pascucci edited this page May 27, 2019 · 8 revisions

INDEX

ANALOGRD(pin)

Read analog value from pin.

PRINT ANALOGRD(15)
534

Read analog value from pin A1 (15 in Arduino Uno).
See analogRead() in Arduino Reference.

ASC(string)

Returns ASCII code for first char in "string"

PRINT ASC("Hello")
72

If string is empty returns 0.

CHR$(num)

Returns a single character string, whose ASCII code is num

PRINT CHR$(33)
!

COS(angle)

Return the cosine of angle. Angles are in degree.

PRINT COS(90)
0

INT(number)

Returns the integer part of a number.

PRINT INT(1.5)
1

LEFT$(string,n)

Returns first n character from "string".

PRINT LEFT$("Hello!",3)
Hel

LEN(string)

Return character count in "string":

PRINT LEN("HELLO!")
6

MID$(string,start,n)

Returns n characters from "string" starting from start.

PRINT MID$("Hello!",3,2)
ll

PINREAD(pin)

Return logical value of an Arduino pin as number: 1 for high, 0 for low.

PRINT PINREAD(12)
1

See digitalRead() in Arduino Reference.

RIGHT$(string,n)

Returns last n characters from "string".

PRINT RIGHT$("Hello!",3)
lo!

SIN(angle)

Return the sine of angle. Angles are in degree.

PRINT SIN(90)
1

STR$(number)

Convert number to string.

PRINT STR$(23)+"AA"
23AA

TAN(angle)

Returns tangent of angle. Anglres are in degree.

PRINT TAN(45)
1

VAL(string)

Evaluate "string" as numeric expression and return result.

PRINT VAL("3*5-2")
13

You can use any numeric function in string.

Clone this wiki locally