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

96
Vistas
Why is my Arduino and P5.js serial connection an equation?

I found out that whatever I get in the p5.js sketch as a serial read is one value (52) minus the second value (48) and then multiplied by 10. This would equal 40 which is the serial output set on the Arduino. I am using the p5.serialcontrol application to build a connection from the browser to the serial port:

let serial;
function setup() {
  createCanvas(400, 400);
  
  serial = new p5.SerialPort();
  serial.open("COM3");
}

function draw() {
  background(220);
  
  let data = serial.read();
  
  console.log(data);// prints 48 then 52 repeateadly
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

All digital values and digital signals are just bits, that can be represented and interpreted as numbers (e.g. binary, octal, decimal or hexadecimal). Even text characters are usually stored and transmitted as bits. ASCII is one of the most common translation tables between characters and numeric values.

48 is the ASCII value for character '0' and 52 is the ASCII value for character '4'. The Arduino is sending the string "40" in a loop and the other side is receiving the numeric ASCII values 48 and 52 in a loop.

The other side doesn't know the data type. It only receives bits. You have to tell the program to interpret these bits as ASCII encoded characters.

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