# Slider Value Delay

**URL:** https://discourse.processing.org/t/slider-value-delay/2629
**Category:** Electronics (Arduino, etc.)
**Created:** [August 14, 2018, 9:24am UTC](https://discourse.processing.org/t/slider-value-delay/2629 "2018-08-14T09:24:07Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [August 31, 2018, 4:41am UTC](https://discourse.processing.org/t/slider-value-delay/2629/15 "2018-08-31T04:41:01Z")

</div>

> [@sandy](#):
>
> The sketch I made consists of two parts

Can you indicate the different parts in your code above? What part are you referring to setting the slider and what part reads the voltage and current?

Notice this code is likely ineffective in `setup`:

```java
if (portSerial.available() >0) {
    delay(100);
    dutycycle=portSerial.readString();
     }

```

When you read serial, you need to do ensure you verify the data you are processing. I dont know if you are getting any errors in the last part of your code. Check this:

```java
    void serialEvent (Serial portSerial)
    {
     String strMasukan = portSerial.readStringUntil ('\n');

    if(strMasukan==null) return; //DO nothing

   
    if(strMasukan.size() < 27) return; //DO nothing

    //If the code makes it this far, it is is very likely you have good data

     String strTegangan = strMasukan.substring (0, 7);
     String strArus = strMasukan.substring (9, 14);
     String strDaya = strMasukan.substring (16, 22);
     String strFaktorDaya = strMasukan.substring (27);

      labelTegangan.setText (strTegangan);
      labelArus.setText (strArus);
      labelDaya.setText (strDaya);
      labelFaktorDaya.setText (strFaktorDaya);
      }

```

A better example [here](https://discourse.processing.org/t/serial-communication-issues-arduino/1032)

Kf

---

_[View the full topic](https://discourse.processing.org/t/slider-value-delay/2629)._
