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
, ...
console.log(board.name); // e.g.) 'pico' for Raspberry Pi Pico.
board.uid
<string>
The Uinque ID of the target board. ex) abcdefg
, serial number of the board
Each board shall return different string value. So uid helps you identify a board.
console.log(board.uid); // e.g.) 'E6XXXXXXXXXXXXXX' for Raspberry Pi Pico.
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.
var gpio = board.gpio(0, OUTPUT);
gpio.high();
board.led(pin)
Returns an instance of LED class. All arguments are passed to the constructor.
var led = board.led(25);
led.on();
board.button(pin[, options])
Returns an instance of Button class. All arguments are passed to the constructor.
var btn0 = board.button(0);
btn0.on('click', () => {
console.log('button clicked');
});
board.pwm(pin[, frequency[, duty]])
Returns an instance of PWM class. All arguments are passed to the constructor.
var pwm1 = board.pwm(1, 100, 0.4);
pwm1.start();
board.adc(pin)
Returns an instance of ADC class. All arguments are passed to the constructor.
var adc3 = board.adc(26);
adc.read(); // Read analog value from pin 26.
board.i2c(bus[, options])
Returns an instance of I2C class. All arguments are passed to the constructor.
var i2c0 = board.i2c(0);
i2c0.write(new Uint8Array([0x6b, 0x00]), 0x68);
i2c0.close();
board.spi(bus[, options])
Returns an instance of SPI class. All arguments are passed to the constructor.
var spi0 = board.spi(0);
spi0.send(new Uint8Array([0x6b, 0x00]));
spi0.close();
board.uart(port[, options])
Returns an instance of UART class. All arguments are passed to the constructor.
var serial0 = board.uart(0);
serial0.write('Hello, world\n');
serial0.close();