質問編集履歴
1
コードの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,7 +32,56 @@
|
|
32
32
|
|
33
33
|
Api Compatibility Level は,NET 2.0になっています。
|
34
34
|
|
35
|
+
###Unityのコード
|
35
36
|
|
37
|
+
```ここに言語を入力
|
38
|
+
using UnityEngine;
|
39
|
+
using System.IO.Ports;
|
40
|
+
|
41
|
+
public class SerialTest : MonoBehaviour
|
42
|
+
{
|
43
|
+
|
44
|
+
SerialPort serialPort;
|
45
|
+
|
46
|
+
void Start()
|
47
|
+
{
|
48
|
+
|
49
|
+
serialPort = new SerialPort("COM13", 9600);
|
50
|
+
serialPort.Open();
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
void OnGUI()
|
55
|
+
{
|
56
|
+
|
57
|
+
GUILayout.Label(serialPort.ReadLine());
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
###Arduinoのコード
|
65
|
+
|
66
|
+
```ここに言語を入力
|
67
|
+
const int AnalogPin = A0;
|
68
|
+
|
69
|
+
void setup() {
|
70
|
+
|
71
|
+
Serial.begin(9600);
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
void loop() {
|
76
|
+
|
77
|
+
Serial.println(analogRead(AnalogPin));
|
78
|
+
|
79
|
+
delay(100);
|
80
|
+
|
81
|
+
}
|
82
|
+
```
|
83
|
+
|
84
|
+
|
36
85
|
###配線の画像
|
37
86
|
|
38
87
|

|