64
edits
Line 42: | Line 42: | ||
2.connect pulse sensor with Unity<br> | 2.connect pulse sensor with Unity<br> | ||
A test was done, in which the pulse data collected from person is used to control the angle of | A test was done, in which the pulse data collected from person is used to control the angle of blocks in Unity.<br> | ||
blocks in Unity.<br> | |||
[https://www.youtube.com/watch?v=RbPW2_f4YVk| Test video:Use pulse sensor in unity3D ]<br> | [https://www.youtube.com/watch?v=RbPW2_f4YVk| Test video:Use pulse sensor in unity3D ]<br> | ||
[[File:connect pulse sensor with Unity.png|left| | [[File:connect pulse sensor with Unity.png|left|200px|]] | ||
———Unity script——————————————————————<br> | |||
using System.Collections;<br> | |||
using System.Collections.Generic;<br> | |||
using UnityEngine;<br> | |||
using System.IO.Ports;<br> | |||
using System.Threading;<br> | |||
public class blockmove : MonoBehaviour {<br> | |||
SerialPort serial = new SerialPort ("/dev/cu.usbmodem1411", 9600);<br> | |||
void Update () {<br> | |||
if (!serial.IsOpen)<br> | |||
serial.Open ();<br> | |||
int rotation = int.Parse (serial.ReadLine ());<br> | |||
transform.localEulerAngles = new Vector3(0, rotation,<br> | |||
0);}}<br> | |||
———Unity script——————————————————————<br> | |||
<br clear="all" /> | <br clear="all" /> |
edits