# Processing + Arduino

**URL:** https://discourse.processing.org/t/processing-arduino/36295
**Category:** Electronics (Arduino, etc.)
**Created:** [April 12, 2022, 10:25am UTC](https://discourse.processing.org/t/processing-arduino/36295 "2022-04-12T10:25:38Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://discourse.processing.org/u/Leonid)
#### Post date: [April 12, 2022, 10:25am UTC](https://discourse.processing.org/t/processing-arduino/36295/1 "2022-04-12T10:25:38Z")

</div>

Hello everyone  
Please help.  
I connected processing and arduino. Sending some data from arduno for processing. Everything seems to be in order. But. At the same time, I want to activate the LED (for example) on the arduino by activating the button on the process.  
Question:  
Why do I send “1” from processing, I see it on the processing monitor, but I don’t see it on the arduino monitor?

At the same time processing is arguing: RuntimeException: Error opening serial port COM7: Port busy

//Arduino Code:  
int butt = 0;  
void setup() {  
Serial.begin(9600);  
}  
void loop() {  
if (Serial.available() \> 0) {  
butt = Serial.read();  
Serial.println(butt);  
}  
}

//Processing Code:  
import processing.serial._;  
import controlP5._;  
Serial myPort;  
ControlP5 cp5;

void setup() {  
myPort = new Serial(this, “COM7”, 9600);

cp5 = new ControlP5(this);  
cp5.addButton(“ON”)  
;  
}

void draw()  
{

}

void ON() {  
myPort.write(1);  
println (1);  
}

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 12, 2022, 10:57am UTC](https://discourse.processing.org/t/processing-arduino/36295/2 "2022-04-12T10:57:18Z")

</div>

check this out

> [@Issue with reading Arduino Port](https://discourse.processing.org/t/issue-with-reading-arduino-port/7846/14):
>
> and when you test your second processing code ( what also is a firmata code ) you changed arduino also from your sketch to firmata? when your processing gives you a 0.0, did you measure voltage at that arduino pin? //\_\_\_\_\_\_\_\_\_\_\_\_ anyhow i try to play with your "second code " and yes, i got 0 too!! now that was bad, as i just loaded firmata test my sketch and connect A0 to 5V and all ok test your sketch and it did not work… so i play until i see something, it was the baud rate !…

---

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://discourse.processing.org/u/Leonid)
#### Post date: [April 12, 2022, 11:20am UTC](https://discourse.processing.org/t/processing-arduino/36295/3 "2022-04-12T11:20:18Z")

</div>

Should I use Firmata? I never saw it.  
None of the tutorials mention this.

[![](https://img.youtube.com/vi/NHUB6PBxI6M/maxresdefault.jpg "Processing and Arduino EP#1 buttons") ](https://www.youtube.com/watch?v=NHUB6PBxI6M)

At the same time, I can control the processing from arduino.

---

<div class="post-metadata">

### Author: ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)
#### Post date: [April 12, 2022, 7:18pm UTC](https://discourse.processing.org/t/processing-arduino/36295/4 "2022-04-12T19:18:32Z")

</div>

Hi @Leonid, When you connect Processing to Arduino there are lots of choices. One of the major ones is

- use the Processing Arduino library which talks to the Firmata sketch in the Arduino
- use my own Processing sketch, talking to my own Arduno sketch.
- use one of the value synchronising libraries (see Processing ref → libraries).

To avoid many of the errors I wrote an [example](https://discourse.processing.org/t/processing-and-arduino-serial-example/31650) with the intention that it works first time with data going both ways. Then you can feed your data in place of the data it uses, and then expand it with more data.

---

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://discourse.processing.org/u/Leonid)
#### Post date: [April 13, 2022, 4:43am UTC](https://discourse.processing.org/t/processing-arduino/36295/5 "2022-04-13T04:43:28Z")

</div>

Thank You Richard, I will investigate your topic. But what is wrong with my simple code ?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 13, 2022, 7:43am UTC](https://discourse.processing.org/t/processing-arduino/36295/6 "2022-04-13T07:43:53Z")

</div>

Maybe it’s com7

Try Serial.list()[1]

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [April 13, 2022, 10:21am UTC](https://discourse.processing.org/t/processing-arduino/36295/7 "2022-04-13T10:21:54Z")

</div>

Hello,

> [@Leonid](#):
>
> At the same time processing is arguing: RuntimeException: Error opening serial port COM7: Port busy

Processing is telling you that the COM7 port is busy; this suggests that the Arduino is connected to your Arduino monitor in your case.

You can make one serial connection with one Arduino COM port to _ **one of these at a time** _:

- Arduino monitor
- Processing
- Another device or software

Try connecting the Arduino to Processing with and without the Arduino monitor connected and see what happens.

Try adding some code to receive the data that the Arduino is sending to Processing with the _Serial.println()_ statement.

There are other options to get data from the Arduino; do a bit of research on this.

`:)`

---

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://discourse.processing.org/u/Leonid)
#### Post date: [April 13, 2022, 10:37am UTC](https://discourse.processing.org/t/processing-arduino/36295/8 "2022-04-13T10:37:47Z")

</div>

I can’t understand this logic.

1. Close Serial Monitor of Ard
2. Start Prc. See the button
3. Push the button
4. See “2” on the Serila monitor of Prc
5. Open Serial Monitor of Ard.
6. Ard says: “Not Connected…”
7. Stop Prc
8. Close Serial Monitor Ard.  
9 Open Serial Monitor Ard  
10 Click Ctrl+Enter  
11 See “10” !!! What is this?

---

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://discourse.processing.org/u/Leonid)
#### Post date: [April 13, 2022, 10:38am UTC](https://discourse.processing.org/t/processing-arduino/36295/9 "2022-04-13T10:38:58Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/e/9eda77bfc71b614a4e6d182aba55bdddbe8dcf61.png)

---

<div class="post-metadata">

### Author: ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)
#### Post date: [April 13, 2022, 11:13am UTC](https://discourse.processing.org/t/processing-arduino/36295/10 "2022-04-13T11:13:52Z")

</div>

Hi

You can’t use Arduino ide serial and processing serial at the same time

Add led to your Arduino to on and off 📴

Run Arduino without connect to ide

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [April 13, 2022, 4:31pm UTC](https://discourse.processing.org/t/processing-arduino/36295/11 "2022-04-13T16:31:43Z")

</div>

Hello @Leonid ,

> [@Leonid](#):
>
> 9 Open Serial Monitor Ard  
> 10 Click Ctrl+Enter  
> 11 See “10” !!! What is this?

Ctrl+Enter sends a newline character to Arduino; you have newline selected and this is shown in your picture.  
A newline character is ‘\n’ which is 10 decimal.  
This is received by the Arduino and sent back to the Arduino Monitor using your code example:  
`Serial.println(butt) // butt = 10;`

I can reproduce this with the Arduino IDE 2.0

`:)`

---

<div class="post-metadata">

### Author: ![Leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Leonid](https://discourse.processing.org/u/Leonid)
#### Post date: [April 14, 2022, 5:22am UTC](https://discourse.processing.org/t/processing-arduino/36295/12 "2022-04-14T05:22:04Z")

</div>

OK. Thank you everyone for support. I have got it. I just connect LED to the arduino pin and swotched it on from the processing’s button. I understood that I only can’t see any data on the arduino’ Serial monitor. Can’t use them in parallell. Great. I will continue to invistigate this proggrams
