File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/data/examples/en/10_Interaction Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * @name Arduino sensor data via WebJack
3
+ * @description WebJack is a way to read data from an Arduino (and other sources)
4
+ * using audio -- it basically turns your Arduino into an audio modem.
5
+ *
6
+ * https://github.com/publiclab/webjack
7
+ *
8
+ * Note: WebJack library must be added to your index.html as
9
+ * <script src="https://webjack.io/dist/webjack.js"></script>
10
+ *
11
+ * Testing audio: https://www.youtube.com/watch?v=GtJW1Dlt3cg
12
+ * Load this sketch onto an Arduino:
13
+ * https://create.arduino.cc/editor/jywarren/023158d8-be51-4c78-99ff-36c63126b554/preview
14
+ * Arduino will output audio from pin 3 + ground. Use microphone or an audio cable.
15
+ */
16
+
17
+ function setup ( ) {
18
+ createCanvas ( 400 , 400 ) ;
19
+ noStroke ( ) ;
20
+ fill ( '#ff00aa22' ) ;
21
+ }
22
+
23
+ // Set up the WebJack connection.
24
+ // Use default profile: https://github.com/publiclab/webjack/blob/master/src/profiles.js
25
+ var profile = WebJack . Profiles [ "SoftModem" ] ;
26
+ var connection = new WebJack . Connection ( profile ) ;
27
+
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 ) ;
33
+
34
+ } ) ;
You can’t perform that action at this time.
0 commit comments