5 – DigitalOutputHelper component
DigitalOutputHelper owns one digital output pin and gives you three methods you can call from any UnityEvent:
| Method | What it does |
|---|---|
| On() | Sets the pin HIGH |
| Off() | Sets the pin LOW |
| Toggle() | Flips it |
Use it for LEDs, relays and buzzers.
Before you start
Section titled “Before you start”The pin must be set to Digital Out in the device profile. In Set Up Arduino, set D13 to Digital Out and click Write Pins Into Profile (or create a new profile). Outputs need the Firmata transport.
1. Add the component
Section titled “1. Add the component”- Create an empty GameObject, for example
LED. - Add Component > SerialInputBridge > Digital Output Helper.
- Set Pin to 13.
| Field | Meaning |
|---|---|
| Serial Manager | Leave empty to use the one on this GameObject, or the first one in the scene. |
| Pin | The output pin. It must be listed as Digital Out in the profile. |
| Send Only On Change | Skip writes that would repeat the last value. Leave on. |
| Invert | Send the opposite level. Use it for relay modules that switch on when the pin is LOW. |
2. Drive it from a UI button
Section titled “2. Drive it from a UI button”- Add a UI > Button to the scene.
- Under the button’s On Click (), click +, drag in the
LEDGameObject and choose DigitalOutputHelper > Toggle.
Press Play and click the button. The board’s LED switches on and off.
3. Drive it from a physical button
Section titled “3. Drive it from a physical button”Combine it with DigitalInputEvent:
- Digital ON → DigitalOutputHelper On
- Digital OFF → DigitalOutputHelper Off
Now the LED follows the button on the board, through Unity.