// Update is called once per frames void Update() { UduinoDevice myDevice = UduinoManager.Instance.GetBoard("myArduinoName"); UduinoManager.Instance.Read(myDevice, "mySensor"); if (Input.GetKeyUp(KeyCode.Alpha1)) { OnClick_1?.Invoke(); } if (Input.GetKeyUp(KeyCode.Alpha2)) { OnClick_2?.Invoke(); } if (Input.GetKeyUp(KeyCode.Alpha3)) { OnClick_3?.Invoke(); } if (Input.GetKeyUp(KeyCode.Alpha4)) { OnClick_4?.Invoke(); } Checker(); }
public void OnDataReceived(string data, UduinoDevice device) { Debug.Log("Received"); UduinoDebugTMP.text = data; //var dataSplited = data.Split(';'); if (dataInput == null) { dataInput = "1;1;1;1"; } else { var dataSplited = data.Split(';'); if (dataSplited[0] != dataCached[0]) { if (dataSplited[0] == "0") { OnClick_1?.Invoke(); Debug.Log("BUTTON_01"); } } if (dataSplited[1] != dataCached[1]) { if (dataSplited[1] == "0") { OnClick_2?.Invoke(); Debug.Log("BUTTON_02"); } } } }
private void Update() { if (sendCommandToFirstArduino) { UduinoDevice firstBoard = UduinoManager.Instance.GetBoard("firstBoard"); UduinoManager.Instance.sendCommand(firstBoard, "startLoop"); sendCommandToFirstArduino = false; } }
void OnDataReceived(string data, UduinoDevice deviceName) { if (data == "1") // wenn Knopf runter gedrückt wird { //kleinsten Winkel im angles Array finden, die entsprechende Seite wird im switch als Bezugsvektor gesetzt for (int i = 0; i < angles.Length; i++) { if (angles[i] == Mathf.Min(angles)) { switch (i) { case 0: referenceVector = transform.up; break; case 1: referenceVector = transform.right; break; case 2: referenceVector = transform.forward; break; case 3: referenceVector = -transform.up; break; case 4: referenceVector = -transform.right; break; case 5: referenceVector = -transform.forward; break; default: referenceVector = transform.up; Debug.Log("Hier ist default case"); break; } } } //Zustand wechseln: if (dreaming == false) //wechsel zu traum { FindActiveSide(); dreaming = true; } else //wechsel zu realität { dreaming = false; } } }
void OnValueReceived(string data, UduinoDevice deviceName) { if (data == "1") { PressedDown(); } else if (data == "0") { PressedUp(); } }
void OnValuesReceived(string data, UduinoDevice device) { if (device.name == "myArduinoName") { sensorOne = int.Parse(data); } else if (device.name == "myOtherArduino") { sensorTwo = int.Parse(data); } }
/// <summary> /// This Method constantly check from serial prints coming in from the arduino, /// if the data coming in is "BL" or "BR" (triggered by the left and right buttons on the Control-Deck) /// it will invoke the ShootL and ShootR methods /// </summary> /// <param name="data"></param> /// <param name="baord"></param> void DataReceived(string data, UduinoDevice baord) { if (data == "BL") { ShootL(); } if (data == "BR") { ShootR(); } }
public void ReadIMU(string data, UduinoDevice device) { try { substr = int.Parse(data.Substring(6, 5)); } catch (System.FormatException) { substr = int.Parse(data.Substring(6, 4)); } }
public void Received(string data, UduinoDevice u) { if (u.name == "firstBoard") { Debug.Log("Receiving: " + data + " from " + u.name); } else { Debug.Log("Receiving: " + data + " from " + u.name); } }
void OnDataReceived(string data, UduinoDevice device) { if (device.name == "firstArduino") { sensorOne = int.Parse(data); } else if (device.name == "secondArduino") { sensorTwo = int.Parse(data); } }
private void DataReceived(string data, UduinoDevice board) { //Debug.Log(data); string[] values = data.Split('\\'); Debug.Log(closesIndex); closes[closesIndex] = (values[0] == "1"); closesIndex += (closesIndex < closes.Length - 1 ? 1 : 1 - closes.Length); doorClosed = true; foreach (bool close in closes) { if (!close) { doorClosed = false; break; } } if (doorClosed) { //this.transform.rotation = initialPos; door.localRotation = doorinitpos; if (!boxCalibration) { transform.rotation *= Quaternion.Euler(parseVector(boxRotation) * boxOffset); } } else { door.rotation *= Quaternion.Euler(parseVector(doorRotation) * doorOffset); } Vector3 parseVector(List <int> indexs) { float x, y, z; if (indexs.Count != 3) { Debug.Log("invalid list!"); x = y = z = 0; } else { string[] vs = values; vs[0] = "0"; x = float.Parse(vs[indexs[0]]) * gyro_normalizer_factor; y = float.Parse(vs[indexs[1]]) * gyro_normalizer_factor; z = float.Parse(vs[indexs[2]]) * gyro_normalizer_factor; } return(new Vector3(x, y, z)); } }
// Different setups for each arduino board void OnBoardConnected(UduinoDevice connectedDevice) { //You can launch specific functions here if (connectedDevice.name == "firstArduino") { firstDevice = connectedDevice; } else if (connectedDevice.name == "secondArduino") { secondDevice = connectedDevice; } }
void Update() { if (UduinoManager.Instance.hasBoardConnected()) { UduinoDevice firstDevice = UduinoManager.Instance.GetBoard("myArduinoName"); UduinoDevice secondDevice = UduinoManager.Instance.GetBoard("myOtherArduino"); UduinoManager.Instance.Read(firstDevice, "myVariable"); UduinoManager.Instance.Read(secondDevice, "mySensor"); Debug.Log(sensorOne); Debug.Log(sensorTwo); } }
public void ReadIMU(string data, UduinoDevice device) { try { string[] values = data.Split('/'); float x = float.Parse(values[0].Trim()); float y = float.Parse(values[1].Trim()); float z = float.Parse(values[2].Trim()); Debug.Log(x + ", " + y + ", " + z); cube.transform.rotation = Quaternion.Lerp(cube.transform.localRotation, new Quaternion(x, y, z, 0), Time.deltaTime * 500f); } catch { } }
void BoardConnected(UduinoDevice device) { // if(UduinoManager.Instance.isConnected()) // implemented in the next version. Safe to remove { pin14 = UduinoManager.Instance.GetPinFromBoard("A14"); UduinoManager.Instance.pinMode(pin14, PinMode.Input); Debug.Log("The pin A14 pinout for Arduino Mega is " + pin14); digitalPin42 = UduinoManager.Instance.GetPinFromBoard("42"); UduinoManager.Instance.pinMode(digitalPin42, PinMode.Output); Debug.Log("The pin 42 pinout for Arduino Mega is " + digitalPin42); } }
public void up(string data, UduinoDevice d) { int i = -1; int.TryParse(data, out i); if (i < 300) { return; } if (i != -1) { target = (float)i; } }
void DataReceived(string value, UduinoDevice board) { //Debug.Log(value); //Used for debugging purpose try { int proximity = int.Parse(value); Counter.gripper_value = proximity; // Debug.Log(proximity); } catch (System.FormatException e) { // Debug.Log("filtered out bad stuff"); } }
void OnBoardConnected(UduinoDevice connectedDevice) { // If you have one baord connected UduinoManager.Instance.SetBoardType(connectedDevice, "Arduino Mega"); //Get the pin for a custom board customPinAnalog = UduinoManager.Instance.GetPinNumberFromBoardType("Arduino Mega", "A14"); // If the board is already set with SetBoardType, you can get the Pin iD by usong customPinAnalog = UduinoManager.Instance.GetPinFromBoard("A14"); UduinoManager.Instance.pinMode(customPinAnalog, PinMode.Input); Debug.Log("The pin A14 pinout for Arduino Mega is " + customPinAnalog); //Get the pin for a custom board customPinDigital = BoardsTypeList.Boards.GetBoardFromName("Arduino Mega").GetPin("42"); // returns 42 UduinoManager.Instance.pinMode(customPinDigital, PinMode.Output); }
void OnBoardConnected(UduinoDevice connectedDevice) { foreach (KeyValuePair <int, Modules> i in mList) { if (connectedDevice.name == i.Value.name) { i.Value.Connected = true; i.Value.device = connectedDevice; } else { i.Value.Connected = false; i.Value.device = null; } } }
void Update() { if (UduinoManager.Instance.hasBoardConnected()) { UduinoDevice firstDevice = UduinoManager.Instance.GetBoard("firstArduino"); UduinoDevice secondDevice = UduinoManager.Instance.GetBoard("secondArduino"); UduinoManager.Instance.sendCommand(firstDevice, "GetVariable"); UduinoManager.Instance.sendCommand(secondDevice, "GetVariable"); Debug.Log("Variable of the first board:" + sensorOne); Debug.Log("Variable of the second board:" + sensorTwo); } else { Debug.Log("The boards have not been detected"); } }
void OnBoardConnected(UduinoDevice connectedDevice) { if (connectedDevice.name == "uduinoBoard") { // Set the pinMode of the first board here. // UduinoManager.Instance.pinMode(connectedDevice, 13, PinMode.Input_pullup); // // You can also add extra settings : // connectedDevice.alwaysRead = false; // connectedDevice.readTimeout = 50; } else if (connectedDevice.name == "uduinoBoard2") { // Set the pinMode of the second board here. // UduinoManager.Instance.pinMode(connectedDevice, 12, PinMode.Output); } }
/// <summary> /// This method pulls raw data from the arduino in the format of "L100", "R60", "L90", /// it checks the starting letter and seperates the values in to independant L and R variables /// </summary> /// <param name="data"></param> /// <param name="baord"></param> void DataReceived(string data, UduinoDevice baord) { if (data[0].ToString() == "R") //check if first letter of data is "R" { R = float.Parse(data.Substring(1)); // removes first letter from the STRING of data and parses it to float //Smooths the value coming from the right sensor to reduce anomoles and twitchy flight smoothR = Mathf.SmoothDamp(smoothR, R, ref Rvelocity, smoothTime); } else if (data[0].ToString() == "L") //check if first letter of data is "L" { L = float.Parse(data.Substring(1)); // removes first letter from the STRING of data and parses it to float //Smooths the value coming from the left sensor to reduce anomoles and twitchy flight smoothL = Mathf.SmoothDamp(smoothL, L, ref Lvelocity, smoothTime); } }
void OnDataReceived(string data, UduinoDevice deviceName) { if (data == "1") { Debug.Log(data); PressedDown(); } else if (data == "0") { Debug.Log(data); PressedUp(); } else { Debug.Log(data); } }
public void ReadIMU(string data, UduinoDevice device) { //Debug.Log(data); string[] values = data.Split('/'); if (values.Length == 5 && values[0] == imuName) // Rotation of the first one { float w = float.Parse(values[1]); float x = float.Parse(values[2]); float y = float.Parse(values[3]); float z = float.Parse(values[4]); } else if (values.Length != 5) { Debug.LogWarning(data); } // Log.Debug("The new rotation is : " + transform.Find("IMU_Object").eulerAngles); }
public void ReadIMU(string data, UduinoDevice device) { //Debug.Log(data); string[] values = data.Split('/'); if (values.Length == 5 && values[0] == imuName) // Rotation of the first one { float w = float.Parse(values[1]); float x = float.Parse(values[2]); float y = float.Parse(values[3]); float z = float.Parse(values[4]); this.transform.localRotation = Quaternion.Lerp(this.transform.localRotation, new Quaternion(w, y, x, z), Time.deltaTime * speedFactor); } else if (values.Length != 5) { Debug.LogWarning(data); } this.transform.parent.transform.eulerAngles = rotationOffset; // Log.Debug("The new rotation is : " + transform.Find("IMU_Object").eulerAngles); }
public void ReadIMU(string data, UduinoDevice device) { //Debug.Log(data); string[] values = data.Split('/'); if (values.Length == 5 && values[0] == imuName) // Rotation of the first one { float w = float.Parse(values[1]); float x = float.Parse(values[2]); float y = float.Parse(values[3]); float z = float.Parse(values[4]); //Aufruf Funktion im ObjectController Script: GetComponent <ObjectController>().handleIMUData(x, y, z, w, speedFactor); } else if (values.Length != 5) { Debug.LogWarning(data); } //this.transform.parent.transform.eulerAngles = rotationOffset; // Log.Debug("The new rotation is : " + transform.Find("IMU_Object").eulerAngles); }
public void Receive(string d, UduinoDevice D) { Debug.Log(d); string[] p = d.Split(' '); if (p.Length == 2) { int a = -1; int.TryParse(p[1], out a); if (a != -1) { if (p[0] == "a") { GetFingerByName("Index").inputTarget(a); } if (p[0] == "b") { GetFingerByName("Middle").inputTarget(a); } } } }
void DataHandler(string data, UduinoDevice board) { string[] elements = data.Split('/'); switch (elements[0]) { case "echo": for (int i = 0; i < 10; i++) { Game.Instance.players[i] = Convert.ToBoolean(elements[i + 1]); } break; case "photo": for (int i = 0; i < 10; i++) { Game.Instance.playersScript.shooting[i] = Convert.ToBoolean(elements[i + 1]); } break; default: break; } }
public void OnDataReceived(string data, UduinoDevice device) { Debug.Log(data); // Use the data as you want ! }
void Update() { UduinoDevice myDevice = UduinoManager.Instance.GetBoard("myArduinoName"); UduinoManager.Instance.Read(myDevice, "mySensor"); // Read every frame the value of the "mySensor" function on our board. }