const { Board, Led } = require('johnny-five'); const board = new Board(); board.on('ready', () => { const led = new Led(13); led.blink(500); });
const { Board, Sensor } = require('johnny-five'); const board = new Board(); board.on('ready', () => { const sensor = new Sensor('A0'); sensor.on('change', () => { const voltage = sensor.value * 0.00488; // convert raw value to voltage const celsius = (voltage - 0.5) * 100; // convert voltage to Celsius const fahrenheit = celsius * 1.8 + 32; // convert Celsius to Fahrenheit console.log(`Temperature: ${celsius.toFixed(2)}°C, ${fahrenheit.toFixed(2)}°F`); }); });
const { Board, Servo } = require('johnny-five'); const board = new Board(); board.on('ready', () => { const servo = new Servo(9); servo.to(0); // rotate to 0 degrees board.wait(1000, () => { servo.to(90); // rotate to 90 degrees board.wait(1000, () => { servo.to(180); // rotate to 180 degrees }); }); });The package library for this example would be `johnny-five`. Overall, Johnny-Five is a powerful and flexible library for working with microcontroller boards and building interesting projects with JavaScript.