Skip to content

Instantly share code, notes, and snippets.

@jasonappah
Created July 10, 2020 19:57
Show Gist options
  • Save jasonappah/4928f9b7874414336e345f9fb7721598 to your computer and use it in GitHub Desktop.
Save jasonappah/4928f9b7874414336e345f9fb7721598 to your computer and use it in GitHub Desktop.
Simple node.js script to test the Serial output of an Arduino.
// 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