Debian Codegraph @

opcodes/serialBegin.xml

raw symbols SCIP
1 <refentry id="serialBegin">
2 <indexterm
3 id="IndexSerialBegin"><primary>serialBegin</primary></indexterm>
4
5 <refentryinfo><title>Serial I/O</title></refentryinfo>
6 <refmeta>
7 <refentrytitle>serialBegin</refentrytitle>
8 </refmeta>
9
10 <refnamediv>
11 <refname>serialBegin</refname>
12 <refpurpose>
13 Open a serial port.
14 </refpurpose>
15 </refnamediv>
16
17 <refsect1>
18 <title>Description</title>
19 <para>Plugin opcode in serial.</para>
20 <para>
21 Open a serial port for arduino.
22 </para>
23 </refsect1>
24
25 <refsect1>
26 <title>Syntax</title>
27 <synopsis>iPort <command>serialBegin</command> SPortName [, ibaudRate]</synopsis>
28 </refsect1>
29
30 <refsect1>
31 <title>Initialization</title>
32 <para>
33 <emphasis>SPortName</emphasis> -- port name number
34 </para>
35 <para>
36 <emphasis>ibaudrate</emphasis> -- serial speed, defaulting to
37 9600 bps.
38 </para>
39 </refsect1>
40
41 <refsect1>
42 <title>Examples</title>
43 <para>
44 Here is an example of the serialBegin opcode. It uses the file <ulink url="examples/serialBegin.csd"><citetitle>serialBegin.csd</citetitle></ulink>.
45 <example>
46 <title>Example of the serialBegin opcode.</title>
47 <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
48 <xi:include href="examples-xml/serialBegin.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
49 </example>
50 This is the matching Arduino code :
51 <screen>
52 void setup() {
53 // enable serial communication
54 Serial.begin(9600);
55
56 // declare pin 9 to be an output:
57 pinMode(9, OUTPUT);
58 }
59
60 void loop() {
61 // only do something if we received something (this should be at csound's k-rate)
62 if (Serial.available()) {
63 // set the brightness of LED (connected to pin 9) to our input value
64 int brightness = Serial.read();
65 analogWrite(9, brightness);
66
67 // while we are here, get our knob value and send it to csound
68 int sensorValue = analogRead(A0);
69 Serial.write(sensorValue/4); // scale to 1-byte range (0-255)
70 }
71 }
72 .....</screen>
73 </para>
74 </refsect1>
75
76 <refsect1>
77 <title>See Also</title>
78 <para><link linkend="nonMIDIdevices"><citetitle>non-MIDI Devices</citetitle></link></para>
79 </refsect1>
80
81 <refsect1>
82 <title>Credits</title>
83 <para>
84 <simplelist>
85 <member>Author: &namematt;</member>
86 <member>2011</member>
87 </simplelist>
88 </para>
89 <para>New in version 5.14</para>
90 </refsect1>
91 </refentry>