File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
src/data/examples/zh-Hans/10_Interaction Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,16 @@ function setup() {
18
18
createCanvas ( 400 , 400 ) ;
19
19
noStroke ( ) ;
20
20
fill ( '#ff00aa22' ) ;
21
+ receiveSensorData ( handleData ) ;
21
22
}
22
23
23
- // Set up the WebJack connection.
24
- // Use default profile: https://github.com/publiclab/webjack/blob/master/src/profiles.js
25
- let profile = WebJack . Profiles [ "SoftModem" ] ;
26
- let connection = new WebJack . Connection ( profile ) ;
24
+ function handleData ( data ) {
27
25
28
- // Runs every time a signal is 'heard'
29
- connection . listen ( function ( data ) {
30
-
31
- // Draw an ellipse at a height corresponding to the value received from the Arduino (sensor)
32
- ellipse ( 400 / 2 , 400 - ( data * 5 ) , 20 , 20 ) ;
26
+ console . log ( data ) ; // output the values to log
27
+ // data[0] is the 1st value, data[1] 2nd, etc.
33
28
34
- } ) ;
29
+ // draw stuff! Browse http://p5js.org/reference/
30
+ background ( '#ddd' ) ;
31
+ ellipse ( 200 , 200 , data [ 0 ] + 10 , data [ 0 ] + 10 ) ;
32
+
33
+ }
You can’t perform that action at this time.
0 commit comments