Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
Arduino webserial data filtering

I have an Arduino kit and a webserial API setup to receive the data into a html div with the id of target.

At the moment it is logging all the data into one stream (there are a few dials and switches on the Arduino).

The data looks like this...

RADI 61 RADI 62 RADI 63 RADI 64 WIND 1 WIND 0 WIND 1

...RADI being a dial value and WIND being an on / off switch.

Is there a way to separate this information into RADI and WIND chunks...ideally into separate HTML text boxes so I can manipulate that data?

Any help would be appreciated

Here is my current javascript code...

document.getElementById('connectButton').addEventListener('click', () => {
    if (navigator.serial) {
    connectSerial();
    } else {
    alert('Web Serial API not supported.');
    }
});

async function connectSerial() {
    const log = document.getElementById('target');
    
    try {
    const port = await navigator.serial.requestPort();
    await port.open({ baudRate: 9600 });
    
    const decoder = new TextDecoderStream();
    
    port.readable.pipeTo(decoder.writable);

    const inputStream = decoder.readable;
    const reader = inputStream.getReader();
    
    while (true) {
        const { value, done } = await reader.read();
        if (value) {
        log.textContent += value + '\n';
        }
        if (done) {
        console.log('[readLoop] DONE', done);
        reader.releaseLock();
        break;
        }
    }
    
    } catch (error) {
    log.innerHTML = error;
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assuming you have a couple of textboxes:

<input id='textbox1'></input>
<input id='textbox2'></input>

You can update your log references to the following:

const log1 = document.getElementById('#textbox1');
const log2 = document.getElementById('#textbox2');

Then in your loop:

if (value) {
    let parse = String(value).split(' ');
    if(parse[0] ?? '' == 'WIND') log1.value = parse[1];
    if(parse[0] ?? '' == 'RADI') log2.value = parse[1];
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda