# Send data from Isadora to Arduino

Think of it as if you were building the circuit in Arduino and you use the message from Isadora to Arduino to turn the circuit on or off.

Work files for Arduino &amp; Isadora are added to this book, screenshots just for show ;)

[![Screenshot 2025-02-05 at 15.48.51.png](https://bookstack.hku.nl/uploads/images/gallery/2025-02/scaled-1680-/screenshot-2025-02-05-at-15-48-51.png)](https://bookstack.hku.nl/uploads/images/gallery/2025-02/screenshot-2025-02-05-at-15-48-51.png)

[![Screenshot 2025-02-05 at 15.49.18.png](https://bookstack.hku.nl/uploads/images/gallery/2025-02/scaled-1680-/screenshot-2025-02-05-at-15-49-18.png)](https://bookstack.hku.nl/uploads/images/gallery/2025-02/screenshot-2025-02-05-at-15-49-18.png)

Files not made by me, for more info contact me (Simone van Dordrecht) or Machiel Veltkamp &lt;machiel.veltkamp@hku.nl&gt;

#### Example project:  
Control motor with Isadora

[![Screenshot 2026-09-14 at 15.32.11.png](https://bookstack.hku.nl/uploads/images/gallery/2026-09/scaled-1680-/screenshot-2026-09-14-at-15-32-11.png)](https://bookstack.hku.nl/uploads/images/gallery/2026-09/screenshot-2026-09-14-at-15-32-11.png)

Download Isadora file:  
[send-value-to-ArduinoV2.izz](https://bookstack.hku.nl/attachments/155)

fixed values:

[![Screenshot 2026-09-29 at 15.16.13.png](https://bookstack.hku.nl/uploads/images/gallery/2026-09/scaled-1680-/screenshot-2026-09-29-at-15-16-13.png)](https://bookstack.hku.nl/uploads/images/gallery/2026-09/screenshot-2026-09-29-at-15-16-13.png)  
or  
Range of values (doesnt work well with motors):

[![Screenshot 2026-09-29 at 15.58.25.png](https://bookstack.hku.nl/uploads/images/gallery/2026-09/scaled-1680-/screenshot-2026-09-29-at-15-58-25.png)](https://bookstack.hku.nl/uploads/images/gallery/2026-09/screenshot-2026-09-29-at-15-58-25.png)

Arduino code:

<div id="bkmrk-%23include-%3Cservo.h%3E-s" style="color: #dae3e3; background-color: #1f272a; font-family: Menlo, Monaco, 'Courier New', monospace; font-weight: normal; font-size: 12px; line-height: 18px; white-space: pre;"><div><span style="color: #c586c0;">\#include</span><span style="color: #dae3e3;"> </span><span style="color: #7fcbcd;">&lt;Servo.h&gt;</span></div>  
<div><span style="color: #dae3e3;">Servo myServo;</span></div><div><span style="color: #0ca1a6;">int</span><span style="color: #dae3e3;"> pos = </span><span style="color: #7fcbcd;">0</span><span style="color: #dae3e3;">;</span></div>  
<div><span style="color: #0ca1a6;">void</span><span style="color: #dae3e3;"> </span><span style="color: #f39c12;">setup</span><span style="color: #dae3e3;">() {</span></div><div><span style="color: #dae3e3;"> </span><span style="color: #f39c12;">Serial</span><span style="color: #dae3e3;">.</span><span style="color: #f39c12;">begin</span><span style="color: #dae3e3;">(</span><span style="color: #7fcbcd;">9600</span><span style="color: #dae3e3;">);</span></div><div><span style="color: #dae3e3;"> </span><span style="color: #f39c12;">myServo</span><span style="color: #dae3e3;">.</span><span style="color: #f39c12;">attach</span><span style="color: #dae3e3;">(</span><span style="color: #7fcbcd;">9</span><span style="color: #dae3e3;">);</span></div><div><span style="color: #dae3e3;">}</span></div>  
<div><span style="color: #0ca1a6;">void</span><span style="color: #dae3e3;"> </span><span style="color: #f39c12;">loop</span><span style="color: #dae3e3;">() {</span></div><div><span style="color: #dae3e3;"> </span><span style="color: #c586c0;">if</span><span style="color: #dae3e3;"> (</span><span style="color: #f39c12;">Serial</span><span style="color: #dae3e3;">.</span><span style="color: #f39c12;">available</span><span style="color: #dae3e3;">() &gt; </span><span style="color: #7fcbcd;">0</span><span style="color: #dae3e3;">) {</span></div><div><span style="color: #dae3e3;"> pos = </span><span style="color: #f39c12;">Serial</span><span style="color: #dae3e3;">.</span><span style="color: #f39c12;">parseInt</span><span style="color: #dae3e3;">();</span><span style="color: #7f8c8d;"> // verwacht een getal 0-180</span></div><div><span style="color: #dae3e3;"> pos = </span><span style="color: #f39c12;">constrain</span><span style="color: #dae3e3;">(pos, </span><span style="color: #7fcbcd;">0</span><span style="color: #dae3e3;">, </span><span style="color: #7fcbcd;">180</span><span style="color: #dae3e3;">);</span></div><div><span style="color: #dae3e3;"> </span><span style="color: #f39c12;">myServo</span><span style="color: #dae3e3;">.</span><span style="color: #f39c12;">write</span><span style="color: #dae3e3;">(pos);</span></div>  
<div><span style="color: #7f8c8d;"> // resterende tekens (zoals de newline) uit de buffer opruimen,</span></div><div><span style="color: #7f8c8d;"> // zodat parseInt() niet nog een keer wordt aangeroepen op een lege regel</span></div><div><span style="color: #dae3e3;"> </span><span style="color: #c586c0;">while</span><span style="color: #dae3e3;"> (</span><span style="color: #f39c12;">Serial</span><span style="color: #dae3e3;">.</span><span style="color: #f39c12;">available</span><span style="color: #dae3e3;">() &gt; </span><span style="color: #7fcbcd;">0</span><span style="color: #dae3e3;">) {</span></div><div><span style="color: #dae3e3;"> </span><span style="color: #f39c12;">Serial</span><span style="color: #dae3e3;">.</span><span style="color: #f39c12;">read</span><span style="color: #dae3e3;">();</span></div><div><span style="color: #dae3e3;"> }</span></div><div><span style="color: #dae3e3;"> }</span></div><div><span style="color: #dae3e3;">}</span></div></div>