:::info Sample code
A working example is available on GitHub — [io_output](https://github.com/obniz/obniz/tree/master/examples/nodejs/plugin/io_output).
:::

## Conflict of IO Control

Since IO and other features can be operated both via the cloud (using **obniz.js**) and locally via **Lua**, conflicts may occur if the same IO is accessed simultaneously.

By default, **obniz.js takes priority**. This means that even if an IO is being used by a Lua script, it may be reset depending on the connection status or commands received from obniz.js.

---

## io.retain(io, boolean)

To restrict a specific IO for Lua use only and deny access from obniz.js, use the `io.retain()` function.

In the following example, **IO 0** is set to Lua-exclusive mode:

```lua
io.retain(0, true);

```

When an IO is set to Lua-exclusive mode using the function above, it behaves as follows:

* **Access from obniz.js is completely disabled.**
* **The IO state is maintained (not reset) even if the internet connection is lost.**

It is highly recommended to secure the IOs you intend to use in Lua by calling `io.retain()` beforehand.

---

## About Peripherals

In addition to GPIO (io), features such as `uart` and `spi` are also shared resources.

Unlike GPIO, these peripherals **automatically become Lua-exclusive** as soon as they are accessed from a Lua script.
