質問編集履歴
2
ソースを見やすくした
test
CHANGED
File without changes
|
test
CHANGED
@@ -314,58 +314,60 @@
|
|
314
314
|
|
315
315
|
|
316
316
|
|
317
|
+
[Arduino]
|
318
|
+
|
319
|
+
#define LED 13
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
void setup() {
|
324
|
+
|
325
|
+
// put your setup code here, to run once:
|
326
|
+
|
327
|
+
pinMode(LED, OUTPUT);
|
328
|
+
|
329
|
+
Serial.begin(9600);
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
//Serial.println("Test");
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
void loop() {
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
int input;
|
344
|
+
|
345
|
+
Serial.write("a");
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
input = Serial.read();
|
350
|
+
|
351
|
+
Serial.println(input);
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
if(input != -1 ){
|
356
|
+
|
357
|
+
Serial.print("LED ON\n");
|
358
|
+
|
359
|
+
digitalWrite(LED, HIGH);
|
360
|
+
|
361
|
+
}else {
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
|
368
|
+
|
317
369
|
```
|
318
370
|
|
319
|
-
```Arduino
|
320
|
-
|
321
|
-
#define LED 13
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
void setup() {
|
326
|
-
|
327
|
-
// put your setup code here, to run once:
|
328
|
-
|
329
|
-
pinMode(LED, OUTPUT);
|
330
|
-
|
331
|
-
Serial.begin(9600);
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
//Serial.println("Test");
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
void loop() {
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
int input;
|
346
|
-
|
347
|
-
Serial.write("a");
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
input = Serial.read();
|
352
|
-
|
353
|
-
Serial.println(input);
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
if(input != -1 ){
|
358
|
-
|
359
|
-
Serial.print("LED ON\n");
|
360
|
-
|
361
|
-
digitalWrite(LED, HIGH);
|
362
|
-
|
363
|
-
}else {
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
}
|
368
|
-
|
369
371
|
|
370
372
|
|
371
373
|
そして、実行すると、Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
|
1
見やすさを更新しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
java -> Arduino Mega
|
2
|
+
|
1
|
-
|
3
|
+
Arduino -> java の双方向のシリアル通信をしたいのですが、うまくいきません。
|
2
|
-
|
4
|
+
|
3
|
-
|
5
|
+
どうすればよいでしょうか?
|
4
|
-
|
6
|
+
|
7
|
+
|
8
|
+
|
5
|
-
|
9
|
+
```java
|
6
10
|
|
7
11
|
import java.io.*;
|
8
12
|
|
@@ -310,7 +314,9 @@
|
|
310
314
|
|
311
315
|
|
312
316
|
|
317
|
+
```
|
318
|
+
|
313
|
-
|
319
|
+
```Arduino
|
314
320
|
|
315
321
|
#define LED 13
|
316
322
|
|
@@ -356,33 +362,7 @@
|
|
356
362
|
|
357
363
|
}else {
|
358
364
|
|
359
|
-
}
|
365
|
+
}
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
/*if(Serial.available()){
|
364
|
-
|
365
|
-
data[i] = Serial.read();
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
if(data[i] == '\0'){
|
370
|
-
|
371
|
-
data[i] = '\0';
|
372
|
-
|
373
|
-
Serial.write("A");
|
374
|
-
|
375
|
-
i = 0;
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
|
-
else {
|
380
|
-
|
381
|
-
i++;
|
382
|
-
|
383
|
-
}
|
384
|
-
|
385
|
-
}*/
|
386
366
|
|
387
367
|
}
|
388
368
|
|