# Processing arduino slave from raspberry pi

**URL:** <https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883>\
**Category:** Processing for Pi\
**Created:** [March 21, 2020, 5:47pm UTC](https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883 "2020-03-21T17:47:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![reaghanpius](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@reaghanpius](https://discourse.processing.org/u/reaghanpius)\
**Post date:** [March 21, 2020, 5:47pm UTC](https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883/1 "2020-03-21T17:47:00Z")

</div>

hi there , im doing a project in which , a dual servo motor (X and Y axis) in a arduino is controled using a Mouse, when i run the processing code from a Windows Pc, it works perfectly , but when i control it from a Raspberry pi running “processing v3”, it gives the Interface window , but the Motor is unresponsive.

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [March 21, 2020, 7:41pm UTC](https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883/2 "2020-03-21T19:41:15Z")

</div>

This is something @kll might be able to answer but you should list model of RaspberryPI and any other relevant details.

---

<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:** [March 21, 2020, 8:16pm UTC](https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883/3 "2020-03-21T20:16:59Z")

</div>

Hello,

Are you connected to the correct serial port?

Try a simple example that just turns an LED on and off and watch the Rx lights on the Arduino side.

> [@Processing to Arduino Serial Library Example](https://discourse.processing.org/t/processing-to-arduino-serial-library-example/11143):
>
> The SimpleWrite example in the Processing examples was not working on PCs I had available to me. The Arduino resets when establishing a serial connection. I added a delay(1000) to allow the Arduino to reset after serial connection to Processing and it now works. I modified the Processing setup() as follows: void setup() { size(200, 200); printArray(Serial.list()); //Added! List all the available serial ports String portName = Serial.list()[0]; myPort = new Serial(this, portNa…

I use [serial pass through](https://www.arduino.cc/en/Tutorial/SerialPassthrough) on receiving Arduino and a “USB-to-TTL serial adapter” to monitor communications between devices when doing development.

---

<div class="post-metadata">

**Author:** ![reaghanpius](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@reaghanpius](https://discourse.processing.org/u/reaghanpius)\
**Post date:** [March 22, 2020, 3:08am UTC](https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883/4 "2020-03-22T03:08:39Z")

</div>

Thanks,  
but The Rx light only “lits” up and the Servo works, perfectly when , running “Proessing software” from Pc (Arduino Connected to the Pc), but when i try to Do the Same thing From a Raspberry pi, (this time arduino connected to the Radpberry pi , and “Processing software” running in the raspberry pi) , the Rx light dont Glow.

heres the code

```auto
//Processing code:
import processing.serial.*;       

int xpos=90; // set x servo's value to mid point (0-180);
int ypos=90; // and the same here
Serial port; // The serial port we will be using

void setup()
{
  size(360, 360);
  frameRate(100);
  println(Serial.list()); // List COM-ports
  //select second com-port from the list (COM3 for my device)
  // You will want to change the [1] to select the correct device
  // Remember the list starts at [0] for the first option.
  port = new Serial(this, Serial.list()[0], 19200);
}

void draw()
{
  fill(175);
  rect(0,0,360,360);
  fill(255,0,0); //rgb value so RED
  rect(180, 175, mouseX-180, 10); //xpos, ypos, width, height
  fill(0,255,0); // and GREEN
  rect(175, 180, 10, mouseY-180);
  update(mouseX, mouseY);
}

void update(int x, int y)
{
  //Calculate servo postion from mouseX
  xpos= x/2;
  ypos = y/2;
  //Output the servo position ( from 0 to 180)
  port.write(xpos+"x");
  port.write(ypos+"y");
}

```

**Heres the Output picture** :

 ![forum](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/76426ffc1432509be34c2881512e95b6dcd1d480.png)

For your Concern, im trying something like , from the video:  
[https://www.youtube.com/watch?v=xrv2ldwO38U](https://www.youtube.com/watch?v=xrv2ldwO38U)

BUT , Instead of Windows , Im Trying it from Raspberry PI.

---

<div class="post-metadata">

**Author:** ![reaghanpius](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@reaghanpius](https://discourse.processing.org/u/reaghanpius)\
**Post date:** [March 22, 2020, 6:09am UTC](https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883/5 "2020-03-22T06:09:02Z")

</div>

found the problem , in the line 14

```auto
port = new Serial(this, Serial.list()[0], 19200);

```

the [0] is turned to [1] , and now it WORKS PERFECTLY…

---

<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:** [March 22, 2020, 6:31am UTC](https://discourse.processing.org/t/processing-arduino-slave-from-raspberry-pi/18883/6 "2020-03-22T06:31:25Z")

</div>

> [@reaghanpius](#):
>
> found the problem

That is great because I was going to fire up my RPi and get this working. `:)`  
I may still do this.

What does your:  
`println(Serial.list()); // List COM-ports`  
show on the RPi?

I assume you are using USB to USB and not the serial GPIO pins.  
Which is it?
