# Error with arduino \<-\> processing code "disabling serialEvent() for COM6 null."

**URL:** <https://discourse.processing.org/t/error-with-arduino-processing-code-disabling-serialevent-for-com6-null/27472>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [January 29, 2021, 10:43pm UTC](https://discourse.processing.org/t/error-with-arduino-processing-code-disabling-serialevent-for-com6-null/27472 "2021-01-29T22:43:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neoncodes](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@Neoncodes](https://discourse.processing.org/u/Neoncodes)\
**Post date:** [January 29, 2021, 10:43pm UTC](https://discourse.processing.org/t/error-with-arduino-processing-code-disabling-serialevent-for-com6-null/27472/1 "2021-01-29T22:43:23Z")

</div>

HI, I’m new in Processing, and i want to use arduino and make rotary encoder as arrows. Unfortunetly i have only Uno, not leonardo, so i wanted to made a code in processing to emulate pressing a key. But evry time i want to run, i have error

> Blockquote Error, disabling serialEvent() for COM6 null.

My code :

> import processing.serial.\*;  
> import java.awt.AWTException;  
> import java.awt.Robot;  
> import java.awt.event.InputEvent;  
> import java.awt.event.KeyEvent;  
> import javax.swing.KeyStroke;  
> Serial MyPort;  
> String KeyString = “”;  
> void setup()  
> {  
> System.out.println(“Hi”);  
> size(300, 300);  
> MyPort = new Serial(this, “COM6”, 9600);// My Arduino is on COM3. Enter the COM on which your Arduino is on.  
> MyPort.bufferUntil(‘\n’);  
> }  
> void draw(){  
> background(237, 240, 241);  
> fill(20, 160, 133); // Green Color  
> stroke(33);  
> strokeWeight(1);  
> textSize(32);  
> textSize(24);  
> fill(33);  
> text(“Status:”, 100, 150);  
> textSize(30);  
> textSize(16);  
> text(“Joystick”, 100, 50);  
> text(KeyString, 100, 170);  
> }  
> void serialEvent(Serial MyPort)throws Exception {  
> KeyString = MyPort.readStringUntil(‘\n’);  
> KeyString = KeyString.substring(0, KeyString.indexOf(‘:’));  
> System.out.println(KeyString);  
> Robot Arduino = new Robot();  
> int KeyToPress;  
> switch(KeyString){  
> case “1” :  
> Arduino.keyPress(38);  
> Arduino.keyRelease(38);  
> break;  
> case “2” :  
> Arduino.keyPress(39);  
> Arduino.keyRelease(39);  
> break;  
> case “3” :  
> Arduino.keyPress(40);  
> Arduino.keyRelease(40);  
> break;  
> case “4” :  
> Arduino.keyPress(37);  
> Arduino.keyRelease(37);  
> break;  
> }  
> }

**Help please!**

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [January 31, 2021, 6:57pm UTC](https://discourse.processing.org/t/error-with-arduino-processing-code-disabling-serialevent-for-com6-null/27472/2 "2021-01-31T18:57:45Z")

</div>

Hi @Neoncodes,

Welcome to the forum 🙂

The error is due to the COM port connection. At which COM Port are you trying to connect your arduino?

Then replace the port and the baud rate in line

```auto
MyPort = new Serial(this, “Your COM port goes here”, insert you baudrate here);

```

The following tutorial should also help you in the first steps 🙂  
[https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all](https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all)

Best regards

---

<div class="post-metadata">

**Author:** ![Neoncodes](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@Neoncodes](https://discourse.processing.org/u/Neoncodes)\
**Post date:** [February 1, 2021, 9:20am UTC](https://discourse.processing.org/t/error-with-arduino-processing-code-disabling-serialevent-for-com6-null/27472/3 "2021-02-01T09:20:44Z")

</div>

Thanks, my arduino is at COM6, and baudrate 9600, so in my code it was ok. I did not find the answer in the link provided either, but thank you for your reply nonetheless.

---

<div class="post-metadata">

**Author:** ![Neoncodes](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@Neoncodes](https://discourse.processing.org/u/Neoncodes)\
**Post date:** [February 2, 2021, 9:53am UTC](https://discourse.processing.org/t/error-with-arduino-processing-code-disabling-serialevent-for-com6-null/27472/4 "2021-02-02T09:53:28Z")

</div>

Case closed, i’ve done it in python. If someone is intrested i post it on arduino project hub.

> **[PC controll by arduino uno/nano. Something like dial](https://create.arduino.cc/projecthub/Mikiklopsiki/pc-controll-by-arduino-uno-nano-something-like-dial-e3704a)**
>
> Joystick to controll pc, using python. By Mikiklopsiki.
