# Control servos using sliders

**URL:** https://discourse.processing.org/t/control-servos-using-sliders/38787
**Category:** Electronics (Arduino, etc.)
**Created:** [September 15, 2022, 8:13pm UTC](https://discourse.processing.org/t/control-servos-using-sliders/38787 "2022-09-15T20:13:02Z")
**Posts on this page:** 1
**Showing post:** 7

<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: [September 18, 2022, 11:44am UTC](https://discourse.processing.org/t/control-servos-using-sliders/38787/7 "2022-09-18T11:44:35Z")

</div>

Hello @jeffmorris1956,

> [@jeffmorris1956](#):
>
> The problem is that serial.write can’t send data to correct servo.

Your posted code did not seem to work for me and sharing my exploration.

I modified your code and used the Arduino code from my previous post to echo back data:

```auto
void setup() 
  {
  size(1200,800);
  myPort = new Serial(this, "COM7", 9600);
  delay(1000); // This did the trick!
  println("Ready!");
  //myPort.bufferUntil('\n');
  cp5 = new ControlP5(this);
  createMessageBox();
  }

void draw() 
  {
  background(0);
  if(myPort.available() > 0)
    {
    int val = myPort.read();
    println("Rx: ", val);
    }
  }

```

Your events:

`myPort.write(val01);`

`myPort.write(val02);`

It only worked on my Arduino Mega 2560 R3 once I added the delay:

` delay(1000); // This did the trick!`

Related:  
[https://discourse.processing.org/t/processing-to-arduino-serial-library-example/11143](https://discourse.processing.org/t/processing-to-arduino-serial-library-example/11143)

The _correct servo_ part you can work on… lots of suggestions and resources out there for that.

`:)`

---

_[View the full topic](https://discourse.processing.org/t/control-servos-using-sliders/38787)._
