找不到模块'serialport'

问题描述 投票:0回答:1

我已经开始一个项目:使用Arduino,node.js,johnny-five控制RGB灯。我指的是https://www.bracketsacademy.com/2018/10/01/how-to-control-arduino-wirelessly-with-web-sockets-and-johnny-five/

然后我收到此错误。 错误:找不到模块'serialport'

const express = require('express');
const app = express();
const port = 3000;

var five = require("johnny-five");
const WebSocket = require('ws');
const wss = new WebSocket.Server({port:8080});

app.listen(port, () => { console.log("we are live") })
app.use('/color',express.static('public'));

five.Board().on('ready',function(){
    var led = new five.Led.RGB({
        pins:{
            red:6,
            green:5,
            blue:3
        }
    });
    led.on();
    led.color('#FF0000');
    wss.on('connection',function(ws,req){
    console.log('connected');
    ws.on('message',function(data){
        led.color('#' + data);
        })
    })
})
node.js rgb arduino-uno johnny-five firmata
1个回答
0
投票

您需要首先设置Arduino,安装StandardFirmataPlus草图。按照first part of the tutorial进行操作。

© www.soinside.com 2019 - 2024. All rights reserved.