Exemple #1
0
 void Update()
 {
     if (!serialPort.IsOpened())
     {
         serialPort.Open();
         Debug.Log("serialport is opening");
     }
     if (Input.GetKeyDown("space") || Input.touchCount > 0)
     {
         Debug.Log("key was pressed");
         Debug.Log("writing");
         serialPort.WriteCRLF("unity");
         Debug.Log("wrote");
     }
 }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (serialPort != null)
     {
         if (serialPort.IsOpened())
         {
             if (Input.GetKeyDown(SendKeyCode))
             {
                 byte[] d = System.Text.Encoding.ASCII.GetBytes("test\0\0byte\0\0test");
                 serialPort.Write(d);
             }
             if (Input.GetKeyDown(SendKeyCode2))
             {
                 serialPort.Write("string data");
             }
         }
     }
 }