質問編集履歴

1

書式の改善

2017/12/19 17:36

投稿

marumori
marumori

スコア8

test CHANGED
File without changes
test CHANGED
@@ -20,37 +20,21 @@
20
20
 
21
21
  ```
22
22
 
23
- //controller.js
24
-
25
- var milkcocoa = new MilkCocoa('yieldjb37t6uz.mlkcca.com');var ds = milkcocoa.dataStore('bb8');
26
-
27
- **$('.square_btn').on('click',function(){ ds.send({v:'kidou'}, (err, sended) => { console.log(sended); });});**
28
-
29
- $('.button1').on('click',function(){ ds.send({v:'forward'}, (err, sended) => { console.log(sended); });}); $('.button2').on('click',function(){ ds.send({v:'back'}, (err, sended) => { console.log(sended); });}); $('.button3').on('click',function(){ ds.send({v:'right'}, (err, sended) => { console.log(sended); });}); $('.button4').on('click',function(){ ds.send({v:'left'}, (err, sended) => { console.log(sended); });}); $('.button6').on('click',function(){ ds.send({v:'red'}, (err, sended) => { console.log(sended); });}); $('.button7').on('click',function(){ ds.send({v:'green'}, (err, sended) => { console.log(sended); });}); $('.button5').on('click',function(){ ds.send({v:'blue'}, (err, sended) => { console.log(sended); });});
30
-
31
- $('.button8').click(function(){window.location.href='question.html';});
32
-
33
- $('.button9').click(function(){window.location.href='/home/pi/mytestapp/mokuji.html';});
34
-
35
-
36
-
37
- ```
38
-
39
-
40
-
41
- ```
42
-
43
23
  <!DOCTYPE html><html lang="ja">
44
24
 
45
25
  <head><meta charset="UTF-8">
46
26
 
47
27
  <script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
48
28
 
29
+
30
+
49
- <script>
31
+ **<script>
50
32
 
51
33
  function kidou(){ let Cylon = require('cylon');Cylon.robot({ connections: { bluetooth: { adaptor: 'central', uuid: 'FBA6D43786FE', module: 'cylon-ble'} },devices: { bb8: { driver: 'bb8', module: 'cylon-sphero-ble'} },work: (my) => {main(my)}}).start();
52
34
 
53
- } </script>
35
+ } </script>**
36
+
37
+
54
38
 
55
39
  <title>Sphero controller</title><script src="http://cdn.mlkcca.com/v0.6.0/milkcocoa.js"></script><script type="text/javascript" src="controller_test.js"></script>
56
40
 
@@ -74,6 +58,46 @@
74
58
 
75
59
  ```
76
60
 
61
+ <script>でロボットを制御するコード(7行目から12行目)を描いたのですが、エラーが出てしまいます。
62
+
63
+ ```
64
+
65
+ require is not defined
66
+
67
+ ```
68
+
69
+ また、squere-btn(接続ボタン)を押すことでロボットと接続できるコードを描いてみたのですが、うまくいきません。
70
+
71
+ ```
72
+
73
+ //controller.js
74
+
75
+ var milkcocoa = new MilkCocoa('milkcocoaのアプリID.mlkcca.com');
76
+
77
+ var ds = milkcocoa.dataStore('bb8');
78
+
79
+
80
+
81
+
82
+
83
+ $('.square_btn').on('click',function(){ ds.send({v:'kidou'}, (err, sended) => { console.log(sended); });});
84
+
85
+
86
+
87
+
88
+
89
+ $('.button1').on('click',function(){ ds.send({v:'forward'}, (err, sended) => { console.log(sended); });}); $('.button2').on('click',function(){ ds.send({v:'back'}, (err, sended) => { console.log(sended); });}); $('.button3').on('click',function(){ ds.send({v:'right'}, (err, sended) => { console.log(sended); });}); $('.button4').on('click',function(){ ds.send({v:'left'}, (err, sended) => { console.log(sended); });}); $('.button6').on('click',function(){ ds.send({v:'red'}, (err, sended) => { console.log(sended); });}); $('.button7').on('click',function(){ ds.send({v:'green'}, (err, sended) => { console.log(sended); });}); $('.button5').on('click',function(){ ds.send({v:'blue'}, (err, sended) => { console.log(sended); });});
90
+
91
+ $('.button8').click(function(){window.location.href='question.html';});
92
+
93
+ $('.button9').click(function(){window.location.href='/home/pi/mytestapp/mokuji.html';});
94
+
95
+
96
+
97
+ ```
98
+
99
+
100
+
77
101
 
78
102
 
79
103
  ```
@@ -82,7 +106,7 @@
82
106
 
83
107
  let MilkCocoa = require('milkcocoa');
84
108
 
85
- let milkcocoa = new MilkCocoa('yieldjb37t6uz.mlkcca.com');
109
+ let milkcocoa = new MilkCocoa('アプリID.mlkcca.com');
86
110
 
87
111
  let ds = milkcocoa.dataStore('bb8');
88
112
 
@@ -99,3 +123,5 @@
99
123
 
100
124
 
101
125
  ```
126
+
127
+ 説明がわかりにくいと思いますが、わかる方がいましたらご教示お願いします。