7.4 KiB
7.4 KiB
Reference
@section full
~column
Basic
basic.showNumber(2)
basic.showString('Hello!')
basic.showLeds(`. . . . .
. # . # .
. . . . .
# . . . #
. # # # .`)
basic.clearScreen()
basic.forever(() => { })
basic.pause(200)
Input
input.onButtonPressed(Button.A, () => {})
input.onPinPressed(TouchPin.P0, () => {})
Loops
for(let i = 0;i<5;i++) {}
while(true) {}
basic.forever(() => {})
~
~column
Logic
if(false) {
}
Boolean values: true; false
true
false
Boolean binary operators: and (conjunction); or (disjunction)
true && false;
true || false;
Boolean negation operator
!true
Comparison operators (=, !=, <, >, <=, >=)
0 == 0;
1 !- 0;
0 < 1;
1 > 0;
0 <= 1;
1 >= 0;
Variables
Assign (set) a variable's value
let x = 0;
Get a variable's value
let x = 0;
x;
Change a variable's value
let x = 0;
x+=1;
Math
Numeric values: 0, 1, 2, ...
0;
1;
2;
Arithmetic binary operation (+, -, *, /)
0+1;
0-1;
1*2;
3/4;
Absolute value
Math.abs(-5);
Minimum/maximum of two values
Math.min(0, 1);
Math.max(0, 1);
Random value
Math.random(5);
LED
led.plot(2,2)
led.unplot(2,2)
led.point(2,2)
led.brightness()
led.setBrightness(255)
led.stopAnimation()
led.plotBarGraph(0, 1023)
Game
Music
Comments
Images
~
~column
Pins
Devices
Functions in this category require to be connected to a remote device.