ArduinoSerial Op

ArduinoSerial

Simlple way to communicated with Arduino Boards using Serial


Web Serial JSON Bridge (cables.gl Op)

A lightweight, real-time serial bridge between cables.gl and microcontrollers (Arduino, ESP32, Raspberry Pi Pico) using the Web Serial API. Communication operates via newline-delimited JSON packets (\n) at a fixed 115200 bps baud rate.

Tailored for workshops, rapid prototyping, and small creative coding projects, this Op favors instant setup over extensive configuration. For simplicity and ease of use in teaching contexts, event-driven digital input handling (debouncing, state changes, internal pull-ups) is deliberately omitted, focusing solely on continuous analog telemetry and direct output control.

A ready-to-use Arduino example sketch is provided as a .zip archive, featuring full servo motor integration alongside standard I/O routines.


Data Protocol

The Op exchanges flat JSON objects between cables.gl and the firmware.

Outputs (cables.gl → Microcontroller)

All outgoing numeric values are rounded to integers and filtered by an anti-spam check to prevent sending duplicate serial frames.

  • Digital* → Maps to digitalWrite() functions (e.g., {"Digital1": 1}, relays, LEDs).
  • PWM* → Maps to Pulse Width Modulation outputs (e.g., {"PWM1": 180}, LED dimming, motor speed).
  • SERVO* → Maps to servo motor position commands (e.g., {"SERVO1": 90}).

Inputs (Microcontroller → cables.gl)

Incoming serial lines are parsed as JSON objects and forwarded to the Received Object output port.

  • Analog* → Maps to continuous analogRead() telemetry (e.g., {"Analog0": 512, "Analog1": 1023}, sensors, potentiometers).

Full Name
  • Ops.Patch.P8FFfwy.ArduinoSerial
VisibilityLicense
  • MIT
AuthorCreated



Arduino Serial - Example

This cables.gl Op provides a lightweight, plug-and-play Web Serial bridge designed for workshops and rapid prototyping, exchanging JSON data at 115200 bps to control servos, PWM, and digital outputs while streaming analog inputs, complete with an included Arduino example sketch in a .zip archive.

Open In Editor

INPUT PORTS


Object To Send (Object)

The JavaScript object to stringify and stream over serial.

Connect (Trigger)

Opens the browser's native serial device selection dialog.

Close Port (Trigger)

Closes the active port and releases reader/writer streams.

Forget All Ports (Trigger)

Revokes persistent device permissions stored in the browser, resetting the port list.

Auto Connect (Number: boolean)

When true, automatically reconnects on load to the first previously authorized device without showing a prompt.

OUTPUT PORTS


Received Object (Object)

Parsed JSON received from the microcontroller.

Connected (booleanNumber)

Connection status (true when active).

Received Lines (Number)

Counter of valid parsed incoming frames.

Has Error (booleanNumber)

Flag set to true when a connection or I/O failure occurs.

Supported (booleanNumber)

Indicates whether the client browser supports the Web Serial API.

Error Message (String)

Detailed description of the latest error.


Changelog

Patches using ArduinoSerial

  • Examples
  • Public
  • My Patches