# How to change images graphically when receiving data?

**URL:** <https://discourse.processing.org/t/how-to-change-images-graphically-when-receiving-data/26523>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [December 26, 2020, 5:26pm UTC](https://discourse.processing.org/t/how-to-change-images-graphically-when-receiving-data/26523 "2020-12-26T17:26:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vadimkuzmin](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@Vadimkuzmin](https://discourse.processing.org/u/Vadimkuzmin)\
**Post date:** [December 26, 2020, 5:26pm UTC](https://discourse.processing.org/t/how-to-change-images-graphically-when-receiving-data/26523/1 "2020-12-26T17:26:17Z")

</div>

> <https://stackoverflow.com/questions/65455042/how-to-change-images-graphically-when-receiving-data>

Good afternoon, I am using a terminal to send data via com-port. I work under the protocol.

In the project, the Displaydata tab contains the string “case 35” - the # symbol.

What to write between case 35: and break; To achieve this?

The OOP JAVA code is used.

The command can be sent through the terminal using a virtual com port.

Command: #, 10 ,! picture 1.

For example: the number 10 could represent the minutes of the picture button.

---

<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:** [December 27, 2020, 12:09am UTC](https://discourse.processing.org/t/how-to-change-images-graphically-when-receiving-data/26523/2 "2020-12-27T00:09:33Z")

</div>

Hello,

This was a quick exploration with your code and managed to get it to update the button when it received serial data as per your protocol.

The Arduino monitor was used to send data.

I added a method to your imageButton class:

```auto
void serButton (String num) {
  min = int(num);
  stateIndex = min/10;
  }

```

Added:

```auto
if (testRead != null)
    {
      println(incomingData);
      x = (int) testRead[0].charAt(0);
      num = testRead[1]; //global String num;
      //button.serButton(num);
     
      println(x, num, button.min);
      Displaydata();
    }

```

Added:

```auto
  case 35:
    // What to write?
    //label(num +" Мин."); // ImageButton #,10,!
    println("Case 35");
    button.serButton(num);
    //println(button.min);
    break;

```

Changed this to easily receive the serial data from Arduino monitor for testing:

```auto
    //incomingData = serialPort.readStringUntil(RC);
    incomingData = serialPort.readStringUntil('\n');

```

`:)`

---

<div class="post-metadata">

**Author:** ![Vadimkuzmin](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@Vadimkuzmin](https://discourse.processing.org/u/Vadimkuzmin)\
**Post date:** [December 27, 2020, 4:50am UTC](https://discourse.processing.org/t/how-to-change-images-graphically-when-receiving-data/26523/3 "2020-12-27T04:50:06Z")

</div>

Thank you very much, happy new year to you.
