Serial Communication API Frontend for Bittle Robot
- Node.js
- npm
- serialport
npm install serialport
read bittle data from the serial port
const SerialPort = require('serialport').SerialPort;
const comPortB = new SerialPort({
path: '/dev/cu.usbmodem56D00039821',
baudRate: 115200,
dataBits: 8,
stopBits: 1,
parity: 'none',
});
comPortB.on('open', function () {
console.log('Serial Port connected');
comPortB.on('data', function (data) {
console.log('>:^.^:>\n' + data);
});
});
write async functions to control the robot
add k to the beginning of the bittle move
and a wait time to the end of the move
async up() {
setTimeout(() => {
this.comPortB.write('kup');
}, 3000);
}
up();