Kaluma
Search…
Board
The board object provide the board specific properties which you are currently using.

Object: board

board.name

  • <string>
The ID of the target board. ex) pico, ...
1
console.log(board.name); // e.g.) 'pico' for Raspberry Pi Pico.
Copied!
For more properties, please check the page for each board.

board.LED

The pin number of the on-board LED.

board.gpio(pin[, mode])

Returns an instance of GPIO class. All arguments are passed to the constructor.
1
var gpio = board.gpio(0, OUTPUT);
2
gpio.high();
Copied!

board.led(pin)

Returns an instance of LED class. All arguments are passed to the constructor.
1
var led = board.led(25);
2
led.on();
Copied!

board.button(pin[, options])

Returns an instance of Button class. All arguments are passed to the constructor.
1
var btn0 = board.button(0);
2
btn0.on('click', () => {
3
console.log('button clicked');
4
});
Copied!

board.pwm(pin[, frequency[, duty]])

Returns an instance of PWM class. All arguments are passed to the constructor.
1
var pwm1 = board.pwm(1, 100, 0.4);
2
pwm1.start();
Copied!

board.adc(pin)

Returns an instance of ADC class. All arguments are passed to the constructor.
1
var adc3 = board.adc(26);
2
adc.read(); // Read analog value from pin 26.
Copied!

board.i2c(bus[, options])

Returns an instance of I2C class. All arguments are passed to the constructor.
1
var i2c0 = board.i2c(0);
2
i2c0.write(new Uint8Array([0x6b, 0x00]), 0x68);
3
i2c0.close();
Copied!

board.spi(bus[, options])

Returns an instance of SPI class. All arguments are passed to the constructor.
1
var spi0 = board.spi(0);
2
spi0.send(new Uint8Array([0x6b, 0x00]));
3
spi0.close();
Copied!

board.uart(port[, options])

Returns an instance of UART class. All arguments are passed to the constructor.
1
var serial0 = board.uart(0);
2
serial0.write('Hello, world\n');
3
serial0.close();
Copied!
Last modified 2mo ago