# Nothing gets sent to Arduino from Processing

**URL:** <https://discourse.processing.org/t/nothing-gets-sent-to-arduino-from-processing/13654>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [August 27, 2019, 8:57pm UTC](https://discourse.processing.org/t/nothing-gets-sent-to-arduino-from-processing/13654 "2019-08-27T20:57:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BeastCoder](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@BeastCoder](https://discourse.processing.org/u/BeastCoder)\
**Post date:** [August 27, 2019, 8:57pm UTC](https://discourse.processing.org/t/nothing-gets-sent-to-arduino-from-processing/13654/1 "2019-08-27T20:57:05Z")

</div>

I have a problem where I kwow that my bluetooth module (HC-05) is connected to a processing sketch, but nothing ever gets sent from the processing sketch,why?

No error messages but the info never gets sent over because I never see it in Arduino, where it would be printed to the Serial Monitor.

Full Processing Code:

```java
import processing.serial.*;
import controlP5.*;

Serial myPort;
ControlP5 cp5;

int slider1 = 0;
int slider2 = 0;
int slider3 = 0;

void setup() {

  size(800, 800);
  cp5 = new ControlP5(this);
  PFont roboto = createFont("Roboto-Bold.ttf", 1, true);
  ControlFont font = new ControlFont(roboto, 28);
  Controller Aslider1 = cp5.addSlider("slider1")
    .setPosition(85, 100)
    .setCaptionLabel("Red")
    .setRange(0, 255)
    .setWidth(191)
    .setHeight(50);
  cp5.getController("slider1").getValueLabel().setFont(font).align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
  cp5.getController("slider1").getCaptionLabel().setFont(font).align(ControlP5.RIGHT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);

  Controller Aslider2 = cp5.addSlider("slider2")
    .setPosition(301, 100)
    .setCaptionLabel("Green")
    .setRange(0, 255)
    .setWidth(191)
    .setHeight(50);
  cp5.getController("slider2").getValueLabel().setFont(font).align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
  cp5.getController("slider2").getCaptionLabel().setFont(font).align(ControlP5.RIGHT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);

  Controller Aslider3 = cp5.addSlider("slider3")
    .setPosition(517, 100)
    .setCaptionLabel("Blue")
    .setRange(0, 255)
    .setWidth(191)
    .setHeight(50);
  cp5.getController("slider3").getValueLabel().setFont(font).align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
  cp5.getController("slider3").getCaptionLabel().setFont(font).align(ControlP5.RIGHT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);

  myPort = new Serial(this, "COM5", 9600);
}

void draw() {
  background(255, 100, 100);

  fill(255);
  stroke(1);
  rectMode(CENTER);
  rect(width/2, 350, 200, 75);

  fill(0);
  textSize(32);
  text("Send", width/2 - textWidth("Send") / 2, 350 + 10);

  if (mouseX > width/2 - 100 && mouseX < width/2 + 100 && mouseY > 350 - 75/2 && mouseY < 350 + 75/2) {
    if (mousePressed) {
      fill(100);
      stroke(1);
      rectMode(CENTER);
      rect(width/2, 350, 200, 75);

      fill(0);
      textSize(32);
      text("Send", width/2 - textWidth("Send") / 2, 350 + 10);
    } else {
      fill(170);
      stroke(1);
      rectMode(CENTER);
      rect(width/2, 350, 200, 75);

      fill(0);
      textSize(32);
      text("Send", width/2 - textWidth("Send") / 2, 350 + 10);
    }
  }
}

void mouseReleased() {
  if (mouseX > width/2 - 100 && mouseX < width/2 + 100 && mouseY > 350 - 75/2 && mouseY < 350 + 75/2) {
    fill(100);
    stroke(1);
    rectMode(CENTER);
    rect(width/2, 350, 200, 75);

    fill(0);
    textSize(32);
    text("Send", width/2 - textWidth("Send") / 2, 350 + 10);

    println(hex(color(int(slider1), int(slider2), int(slider3))).toString().substring(2));
    myPort.write(hex(color(int(slider1), int(slider2), int(slider3))).toString().substring(2));
    myPort.clear();
  }
}

```

Full Arduino Code:

```auto
#include <SoftwareSerial.h>
#include <Adafruit_NeoPixel.h>

const int PIN = 6;
const int NUMPIXELS = 30;

const byte rxPin = 2;
const byte txPin = 3;
SoftwareSerial mySerial (rxPin, txPin);

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

unsigned long currentMillis;
unsigned long loopMillis;
unsigned long waitMillis;
int interval = 100;
int waitInterval = 0;
int redBrightness = 0;
int greenBrightness = 0;
int blueBrightness = 0;
bool wait = false;
bool goToRed = true;
bool goToOrange = false;
bool goToYellow = false;
bool goToGreen = false;
bool goToAqua = false;
bool goToPurple = false;

String hexValue;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  mySerial.begin(9600);
  pixels.begin();
  pixels.show();
}

void loop() {

  if (mySerial.available() > 0) {
    hexValue = mySerial.read();
    Serial.println(hexValue);
    if (hexValue != "shiftN" || hexValue != "shiftY") {
      shiftMode = false;
      // value is a hex
      redBrightness = hexValue.substring(0, 2).toInt();
      greenBrightness = hexValue.substring(2, 4).toInt();
      greenBrightness = hexValue.substring(4, 6).toInt();
    } else {
      if (hexValue = "shiftY") {
        shiftMode = true;
      } else {
        shiftMode = false;
      }
    }
  }

  pixels.show();

  setColor(redBrightness, greenBrightness, blueBrightness);

}

void setColor(int red, int green, int blue) {
  for (int i = 0; i < NUMPIXELS; i++) {
    pixels.setPixelColor(i, red, green, blue);
  }
}

```

Thanks for the help, cheers!

> <https://stackoverflow.com/questions/57679763/nothing-gets-sent-to-arduino-from-processing>

> <https://arduino.stackexchange.com/questions/68233/nothing-gets-sent-to-arduino-from-processing>

[https://forum.arduino.cc/index.php?board=11.0](https://forum.arduino.cc/index.php?board=11.0)

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [August 28, 2019, 9:50pm UTC](https://discourse.processing.org/t/nothing-gets-sent-to-arduino-from-processing/13654/2 "2019-08-28T21:50:02Z")

</div>

ok, looks like even asking at 4 forums did not help too much.

– i not know that HC-05 link hardware for arduino

– you have a print diagnostic from processing AND  
can connect USB arduino to PC arduino IDE and run monitor  
**this 2 outprints could help if posted here**  
( does your error description mean there is NOTHING ( not one byte )  
in the arduino? serial1 input )

– what i miss from your info is that you not talk about the pairing / password and finding  
port ( from processing )  
but COM5 could be that ( or is it the arduino USB port ?)

++ one note to your code:  
while the processing

```auto
myPort.write();

```

is able to send STRING,

_i am thinking_ that the arduino counter part you used:

```auto
String hexValue;

hexValue = mySerial.read();

```

can only read ONE BYTE  
[https://www.arduino.cc/en/Reference/SoftwareSerialRead](https://www.arduino.cc/en/Reference/SoftwareSerialRead)  
[https://www.arduino.cc/reference/en/language/functions/communication/serial/read/](https://www.arduino.cc/reference/en/language/functions/communication/serial/read/) ( thinks same )  
and as you not aggregate these bytes your variable will ever max contain one byte and the following string compare might never work.

---

<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:** [August 29, 2019, 2:45am UTC](https://discourse.processing.org/t/nothing-gets-sent-to-arduino-from-processing/13654/3 "2019-08-29T02:45:59Z")

</div>

I use this app to control RGB LEDs on Arduino with an HC-05:

> <https://play.google.com/store/apps/details?id=nextprototypes.bluetoothtRGB>
>
> Simple Bluetooth RGB controller...

In the settings, you can (hint) add a header or trailer to the RGB data as well as many more options.

This example does what you are trying to do except it is from Arduino to processing:

[![](https://img.youtube.com/vi/CDESqfGP6LE/maxresdefault.jpg "RGB Arduino to Processing") ](https://www.youtube.com/watch?v=CDESqfGP6LE)

I was tinkering with the code to see what it was doing:

```auto
import processing.serial.*;

Serial myPort;

int slider1 = 255;
int slider2 = 0;
int slider3 = 128;

void setup() 
  {
  size(800, 800);
  myPort = new Serial(this, "COM5", 9600);
  }

void draw() 
  {
  background(255, 100, 100);
  }

void mouseReleased()
  {
  myPort.write(hex(color(int(slider1), int(slider2), int(slider3))).toString().substring(2));
  println(hex(color(int(slider1), int(slider2), int(slider3))).toString().substring(2));
  println(hex(slider1,2)+hex(slider2,2)+hex(slider3,2));
  String s = hex(slider1,2)+hex(slider2,2)+hex(slider3,2);
  myPort.write(s);
  println(s);
  myPort.clear();
  }

```

Code (above) writes to a PuTTY terminal on a receiving serial port (could have been an HC-05):

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b3635c8a50af098d0d01ea04b5af88c43d0828a0.png)

Keep at it and you will figure out what to do.

🙂
