Everything is in the Syazmedia.SerialInputBridge namespace:
using Syazmedia . SerialInputBridge ;
Most runtime scripts compile only when the SERIAL_INPUT_BRIDGE define is set, which happens automatically under .NET Framework. Wrap your own scripts that use these types in #if SERIAL_INPUT_BRIDGE ... #endif if the project might run on .NET Standard.
Opens the serial port, talks to the board and receives lines. One per board.
Field
Type
Default
Description
deviceProfile
SerialDeviceProfile
Required. Pins, transport and baud rate.
portName
string
""
Leave blank to pick the most likely Arduino port automatically (USB serial first, COM1 and Bluetooth last). Chosen again on every connect.
baudRate
int
115200
Read-only in practice: taken from the profile.
dtrEnable
bool
true
Assert DTR when opening. Needed by native-USB boards (Leonardo, Micro, many ESP32-S2/S3 and RP2040). Resets Uno/Nano/Mega on open, which is harmless.
autoConnectOnStart
bool
true
Connect in Start().
autoReconnect
bool
false
Retry when the connection drops.
reconnectInterval
float
5
Seconds between retries.
logIncomingLines
bool
false
Print each received line to the Console.
warnOnGibberish
bool
true
Warn about and drop lines that are mostly unreadable (usually a baud mismatch).
Event
Type
When
OnSerialConnected
UnityEvent
The port opened.
OnSerialDisconnected
UnityEvent
The port closed.
OnLineReceived
UnityEvent<string>
A line arrived. With Firmata, inputs arrive as lines in the custom text format too.
Property
Type
Description
IsOpen
bool
The serial port is open.
IsFirmataReady
bool
Firmata only: the board answered and pin setup was sent. Outputs are ignored until then.
ActivePortName
string
The port actually opened, including an auto-selected one. Null before the first connect.
RecentLines
IReadOnlyList<SerialLine>
Recently received lines with timestamps.
Method
Description
StartSerial()
Opens the port (closing it first if open). Called for you when autoConnectOnStart is on.
StopSerial()
Closes the port. Outputs are switched off.
SetDigitalOutput(int pin, bool state)
Firmata: sets a Digital Out pin high or low.
SetPwmOutput(int pin, int value)
Firmata: sets a PWM Out pin, 0–255.
SetServoOutput(int pin, int angleDegrees)
Firmata: points a Servo Out pin, 0–180°.
SendLine(string line)
Writes a line of text to the port. For your own commands with a custom sketch.
ClearRecentLines()
Empties RecentLines.
The output methods only work for pins listed under that role in the profile. Wait for IsFirmataReady before calling them, or use the output helpers , which wait for you.
using Syazmedia . SerialInputBridge ;
public class Blink : MonoBehaviour
public SerialManager serial;
if ( ! serial . IsFirmataReady ) return ;
serial . SetDigitalOutput ( 13 , ( int )t % 2 == 0 );
Turns received lines into Input System controls. Must be on the same GameObject as the SerialManager (the SerialInputBridge prefab has both). Not needed for an output-only setup.
Member
Type
Description
warnOnUnmatchedKeys
bool
Warn once per unknown name, such as D7 when D7 isn’t an input.
targetDevice
InputDevice
The Input System device created for the profile.
OnUnmatchedKey
event Action<string>
Raised for each name with no matching control.
A ScriptableObject describing one board. Create it with Set Up Arduino rather than by hand.
Field
Type
Description
transport
SerialTransport
Firmata or CustomText.
baudRate
int
57600 for Firmata; 115200 for generated custom sketches.
layoutName
string
Input System layout name of the device.
digitalActiveLow
bool
On (default): LOW = pressed, for buttons wired to GND with the internal pull-up.
digitalPins
List<int>
Digital input pins. Become D<pin> controls.
analogChannels
List<int>
Analog input channels (0 = A0). Become A<channel> controls, 0–1.
analogMaxValue
int
Raw value that maps to 1.0. 1023 for 10-bit boards, 4095 for 12-bit.
digitalOutputPins
List<int>
Firmata: digital output pins.
pwmOutputPins
List<int>
Firmata: PWM output pins.
servoOutputPins
List<int>
Firmata: servo output pins.
A pin listed under two roles is left unconfigured, and the Console says which. This avoids driving a pin that’s wired as an input.
Member
Type
Description
actionReference
InputActionReference
The analog action, for example A0.
onValueChanged
UnityEvent<float>
The value, 0–1, whenever it changes (and 0 when the action is canceled).
Member
Type
Description
actionReference
InputActionReference
The button action, for example D2.
digitalON
UnityEvent
Pressed.
digitalOFF
UnityEvent
Released.
Both enable their action and only unsubscribe on disable, so several components can share one action.
Add Component > SerialInputBridge > … . Each helper owns one pin, waits until the board is ready, and sends its last value again if the board restarts.
Field
Type
Default
Description
serialManager
SerialManager
Leave empty for the one on this GameObject, or the first in the scene.
pin
int
13
Must be listed under the helper’s role in the profile.
sendOnlyOnChange
bool
true
Skip writes that repeat the last value.
IsReady
bool (read-only)
The board is ready for writes.
Member
Description
invert
Send the opposite level (for relays that switch on when LOW).
On(), Off(), Toggle()
Switch the pin.
SetState(bool on)
Switch the pin from a bool.
State
The last state you asked for.
Method
Description
SetValue01(float value)
0 (off) to 1 (full).
SetValueRaw(float value)
0 to 255.
Member
Description
minAngle, maxAngle
Range used by SetValue01 (0–180).
SetAngle(float degrees)
0–180°.
SetValue01(float value)
0 → minAngle, 1 → maxAngle.