Page 1 of 1

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!

What function could...
Clear all

What function could I use to send values to Arduino uno with node js?

New Member
Joined: 4 weeks ago
Posts: 1
Topic starter  

I have a problem, my code in Arduino allows me to send values to turn on a led with (), but when I do it with node js port.write () I have tried several ways but it does not turn on the led.

Arduino code

int pin = 12;
String vali="OFF";
char val;

void setup() {

void loop() {
  val =;
  if(val == '1'){
  else if(val == '0'){
    Serial.println(" estado:"+ vali );


js code

const Serialport = require('serialport');
const readline = Serialport.parsers.Readline;
var val = 0;
const port = new Serialport('COM3', {
    baudRate: 9600
const parse = port.pipe(new readline({ delimiter: '\r\n' }));

port.on('open', function() {
    console.log('conect ');


parse.on("data", (data) => {




code from arduino books.

Prominent Member Admin
Joined: 9 years ago
Posts: 996

I honestly have never used JS to write to a serial port ...

However, and I could be very wrong of course, you're using a readline parser?
Somehow sounds wrong ...
Maybe these examples help you in the right direction?
Not sure if that is helpful. 😊 

New Member
Joined: 2 months ago
Posts: 1

thank you for the tip


Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).