Created
July 10, 2020 19:57
-
-
Save jasonappah/4928f9b7874414336e345f9fb7721598 to your computer and use it in GitHub Desktop.
Simple node.js script to test the Serial output of an Arduino.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run 'npm i serialport terminal-overwrite' before running this! | |
const SerialPort = require('serialport') | |
const Readline = require('@serialport/parser-readline') | |
const terminalOverwrite = require('terminal-overwrite'); | |
const BAUD_RATE=9600 | |
const PORT="ENTERYOURPORTHERE" | |
const port = new SerialPort(PORT, { baudRate: BAUD_RATE }) | |
const parser = new Readline() | |
port.pipe(parser) | |
parser.on('data', terminalOverwrite) | |
console.log('Press a key at any time to exit...'); | |
process.stdin.setRawMode(true); | |
process.stdin.resume(); | |
process.stdin.on('data', process.exit.bind(process, 0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment