Initialization and setup

Description
Create a new digital Pin and setup the mode if the pin is not registered. If the pin exsists, change only the mode
Parameters
NameDescription
pin intto initialize
mode PinModePinMode to init pin
Example
void Setup() {
UduinoManager.Instance.pinMode(9, PinMode.Output);
}
Description
Create a new analog Pin and setup the mode if the pin is not registered. If the pin exsists, change only the mode
Parameters
NameDescription
pin AnalogPinAnalog pin to initialize
mode PinModePinMode to init pin
Example
void Setup() {
UduinoManager.Instance.pinMode(AnalogPin.A0, PinMode.Input);
}
Description
Change the pinMode of an analog pin on a specific board, when multiple boards are connected.
Parameters
NameDescription
target UduinoDeviceTarget object
pin AnalogPinto init
mode PinModePinMode to init pin
Example
void Setup() {
UduinoManager.Instance.OnBoardConnected += OnBoardConnected;
}
void OnBoardConnected(UduinoDevice connectedDevice)
{
if (connectedDevice.name == "uduinoBoard") {
UduinoManager.Instance.pinMode(connectedDevice, 9, PinMode.Servo);
}
else if (connectedDevice.name == "otherBoard") {
UduinoManager.Instance.pinMode(connectedDevice, AnalogPin.10, PinMode.Input);
}
}
Description
Change the pinMode of a digital pin on a specific board, when multiple boards are connected.
Parameters
NameDescription
target UduinoDeviceTarget object
pin intto init
mode PinModePinMode to init pin
Example
void Setup() {
UduinoManager.Instance.OnBoardConnected += OnBoardConnected;
}
void OnBoardConnected(UduinoDevice connectedDevice)
{
if (connectedDevice.name == "uduinoBoard") {
UduinoManager.Instance.pinMode(connectedDevice, 9, PinMode.Servo);
}
else if (connectedDevice.name == "otherBoard") {
UduinoManager.Instance.pinMode(connectedDevice, AnalogPin.10, PinMode.Input);
}
}

Send a command

Description
Send a custom command to the Arduino
Parameters
NameDescription
command stringCommand Name
value object[]List of any parameters. This object is later cast as string
Example
void Update() {
UduinoManager.Instance.sendCommand("turnLED", "on"); //or "off"
UduinoManager.Instance.sendCommand("setBrightness", 20, 150, 255);
}
Description
Send a custom command to a specific Arduino, when multiple boards are connected
Parameters
NameDescription
command stringCommand Name
target stringCommand Name
value object[]List of any parameters. This object is later cast as string
Example
void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoardName");
UduinoManager.Instance.sendCommand(board, "turnLED", "on"); //or "off"
UduinoManager.Instance.sendCommand(board, "setBrightness", 20, 150, 255);
}
Description
Send a custom command to Arduino, with the message as an unique string
Parameters
NameDescription
target UduinoDeviceTarget device
message stringMessage to write, including command and parameters
bundle stringOptional bundle name
Example
void Update() {
string message = UduinoManager.BuildMessageParameters(10, "on", 255, "off");
UduinoManager.Instance.sendCommand("setBrightness", message);
}

Digital Read/Write

Description
Write a digital value to a pin
Parameters
NameDescription
pin intTarget Pin
Example
void Start() {
UduinoManager.Instance.pinMode(9, PinMode.Output);
}

void Update() {
UduinoManager.Instance.digitalWrite(9, 150);
}
Description
Write a digital value to a pin
Parameters
NameDescription
pin intTarget Pin
Example
void Start() {
UduinoManager.Instance.pinMode(13, PinMode.Output);
}

void Update() {
UduinoManager.Instance.digitalWrite(13, PinMode.HIGH);
}
Description
Write a digital value to a pin
Parameters
NameDescription
target UduinoDeviceTarget board
pin intTarget Pin
value intValue to send, either 0 or 255 [high or low]
bundle stringOptional Bundle
Example
void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoard");
UduinoManager.Instance.digitalWrite(board, 9, 255);
}
Description
Write a digital value to a pin
Parameters
NameDescription
target UduinoDeviceTarget board
Example
void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoard");
UduinoManager.Instance.digitalWrite(board, 13, PinMode.LOW);
}
Description
Reading a digital value (eg. button)
Parameters
NameDescription
pin intTarget Pin
Returns

Digital value as int

NameDescription
Example
void Start() {
UduinoManager.Instance.pinMode(13, PinMode.Input_Pullup);
}

void Update() {
int buttonValue = UduinoManager.Instance.digitalRead(13);
Debug.Log(buttonValue);
}
Description
Read a digital value (ex button)
Parameters
NameDescription
target UduinoDeviceTarget board
Returns

Digital Value as int

NameDescription
Example
void Start() {
UduinoManager.Instance.pinMode(4, PinMode.Input_Pullup);
}

void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoard");
int buttonValue = UduinoManager.Instance.digitalRead(board, 4);
Debug.Log(buttonValue);
}

Analog Read/Write

Description
Write an analog value to Arduino
Parameters
NameDescription
pin intPin to write
value intValue from 0 to 255
bundle stringOptional Bundle
Example
void Start() {
UduinoManager.Instance.pinMode(6, PinMode.Output);
}

void Update() {
UduinoManager.Instance.analogWrite(6, 145);
}
Description
Write an analog value to Arduino
Parameters
NameDescription
target UduinoDeviceTarget board
pin intPin to write
value intValue from 0 to 255
bundle stringOptional Bundle
Example
void Start() {
UduinoManager.Instance.pinMode(6, PinMode.Output);
}

void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoard");
UduinoManager.Instance.analogWrite(board, 6, 79);
}
Description
Read an analog pin
Parameters
NameDescription
pin AnalogPinAnalog pin to read
bundle stringOptional Bundle
Returns

Analog value as int, range 0-1024

NameDescription
Example
void Start() {
UduinoManager.Instance.pinMode(AnalogPin.A0, PinMode.Input);
}
void Update() {
int value = UduinoManager.Instance.analogRead(AnalogPin.A0);
Debug.Log(value);
}
Description
Read an analog pin
Parameters
NameDescription
pin intPin to read, as int. See the pinout of your board.
bundle stringOptional Bundle
Returns

Analog value as int, range 0-1024

NameDescription
Example
void Start() {
UduinoManager.Instance.pinMode(18, PinMode.Input); // In arduino uno, pin 18 is the pin A4
}
void Update() {
int value = UduinoManager.Instance.analogRead(18);
Debug.Log(value);
}
Description
Read an analog pin
Parameters
NameDescription
target UduinoDeviceTarget board
pin AnalogPinPin to read
bundle stringOptional Bundle
Returns

Analog value as int, range 0-1024

NameDescription
Example

void Start() {
UduinoManager.Instance.pinMode(AnalogPin.A0, PinMode.Input); // In arduino uno, pin 18 is the pin A4
}
void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoardName");
int value = UduinoManager.Instance.analogRead(board, AnalogPin.A0);
Debug.Log(value);
}
Description
Read an analog pin
Parameters
NameDescription
target UduinoDeviceTarget board
pin intPin to read
bundle stringOptional Bundle
Returns

Analog value as int, range 0-1024

NameDescription
Example

void Start() {
UduinoManager.Instance.pinMode(18, PinMode.Input); // In arduino uno, pin 18 is the pin A4
}
void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoardName");
int value = UduinoManager.Instance.analogRead(board, 18);
Debug.Log(value);
}

Message Bundle

Description
Send an existing message bundle to Arduino
Parameters
NameDescription
target UduinoDeviceUduino Device
bundleName stringBundle name
Example
void Update() {
UduinoDevice board = UduinoManager.Instance.GetBaord("uduinoBoardName");
UduinoManager.Instance.SendBundle(board, "bundleName");
}
Description
Build a Uduino message from a list of elements
Parameters
NameDescription
parameters object[]List of a variable number of parameters
Returns
string: Return a string composed of the array elements, separated by the parameter delimiter
NameDescription
Example
void Update() {
string message = UduinoManager.BuildMessageParameters(10, "on", 255, "off");
UduinoManager.Instance.sendCommand("setBrightness", message);
}
Description
Send an existing message bundle to Arduino
Parameters
NameDescription
bundleName stringBundle name
Example
void Update() {
UduinoManager.Instance.SendBundle("bundleName");
}

Board and Pin settings

Description
Set the board type, when only one board is connected.
Parameters
NameDescription
Board Type Type of BoardArduino Uno, Arduino Duemilanove, Arduino Leonardo, Arduino Pro Mini,Arduino Mega, Arduino Due, Arduino Nano, Arduino Mini
Example
void Setup() {
UduinoManager.Instance.SetBoardType("Arduino Mega");
customPinAnalog = UduinoManager.Instance.GetPinNumberFromBoardType("Arduino Mega", 52);
UduinoManager.Instance.pinMode(customPinAnalog, PinMode.Output);
}
Description
Set the board type of a specific arduino board
Parameters
NameDescription
target UduinoDeviceTarget Arduino Board
Board Type Type of boardArduino Uno, Arduino Duemilanove, Arduino Leonardo, Arduino Pro Mini,Arduino Mega, Arduino Due, Arduino Nano, Arduino Mini
Example
void Setup() {
UduinoManager.Instance.OnBoardConnected += OnBoardConnected;
}
void OnBoardConnected(UduinoDevice connectedDevice)
{
if (connectedDevice.name == "uduinoBoard") {
UduinoManager.Instance.SetBoardType(connectedDevice, "Arduino Mega");
} else if (connectedDevice.name == "otherBoard") {
UduinoManager.Instance.SetBoardType(connectedDevice, "Arduino Uno");
}
}
Description
Get the pin int id from specific board type
Parameters
NameDescription
boardType stringType of Arduino board
pin stringPin to find (Digital or Analog
Returns
NameDescription
Arduino pin intThe id of the arduino pin of this board
Example
void Setup() {
UduinoManager.Instance.SetBoardType("Arduino Mega");
customPinAnalog = UduinoManager.Instance.GetPinNumberFromBoardType("Arduino Mega", "A14");
UduinoManager.Instance.pinMode(customPinAnalog, PinMode.Input);
}
Description
Get the pin from specific board type
Parameters
NameDescription
boardType stringType of Arduino board
pin intPin to find (Digital
Returns
NameDescription
Arduino pin intThe id of the arduino pin of this board
Example
void Setup() {
UduinoManager.Instance.SetBoardType("Arduino Mega");
customPinAnalog = UduinoManager.Instance.GetPinNumberFromBoardType("Arduino Mega", 52);
UduinoManager.Instance.pinMode(customPinAnalog, PinMode.Output);
}
Description
Set read callback for all connected boards
Parameters
NameDescription
callback ActionCallback function
Returns
NameDescription
callback ActionCallback function
Example
void Start() {
UduinoManager.Instance.SetReadCallback(ValueReceived);
}

void ValueReceived(string value) {
Debug.Log(value);
}
Description
Set read callback of a specific board
Parameters
NameDescription
target UduinoDeviceTarget device
Example
void Setup() {
UduinoManager.Instance.OnBoardConnected += OnBoardConnected;
}

void OnBoardConnected(UduinoDevice connectedDevice)
{
if (connectedDevice.name == "uduinoBoard") {
UduinoManager.Instance.SetReadCallback(connectedDevice, ValueReceivedBoardOne);
}
else if (connectedDevice.name == "otherBoard") {
UduinoManager.Instance.pinMode(connectedDevice, ValueReceivedBoardTwo);
}
}

void ValueReceivedBoardOne(string value) {
Debug.Log(value);
}

void ValueReceivedBoardTwo(string value) {
Debug.Log(value);
}

Other methods

Description
Find and register all boards connected
Description
Display in console the current state of all boards
Description
Close all opened serial ports

Deprecated

These functions were present in Uduino 1.4.3
but have been deprecated in Uduino 2.0.0+

Description
Initialize an arduino pin
Parameters
NameDescription
pin intto initialize
mode PinModePinMode to init pin
Description
Init a pin
Parameters
NameDescription
pin AnalogPinAnalog pin to initialize
mode PinModePinMode to init pin
Description
Init a pin
Parameters
NameDescription
target stringTarget Name
pin AnalogPinto init
mode PinModePinMode to init pin
Description
Create a new Pin and setup the mode if the pin is not registered. If the pin exsists, change only the mode
Parameters
NameDescription
target stringTarget Name
pin intto init
mode PinModePinMode to init pin
Description
Send a read command to a specific arduino. A read command will be returned in the OnValueReceived() delegate function
Parameters
NameDescription
target stringTarget device name. Not defined means read everything
message stringVariable watched, if defined
timeout intRead Timeout, if defined
action ActionAction callback
Description
Write a command on an Arduino
Parameters
NameDescription
target stringTarget device
message stringMessage to write in the serial
Description
Write a command on an Arduino with a specific value
Parameters
NameDescription
target stringTarget device
message stringMessage to write in the serial
value intOptional value
Description
Replaced with CloseAllDevices()
Parameters
NameDescription
name intdesc