# How do I send variables from text fields in processing to Arduino?

**URL:** <https://discourse.processing.org/t/how-do-i-send-variables-from-text-fields-in-processing-to-arduino/5691>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [November 18, 2018, 8:59pm UTC](https://discourse.processing.org/t/how-do-i-send-variables-from-text-fields-in-processing-to-arduino/5691 "2018-11-18T20:59:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahrokh](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mahrokh](https://discourse.processing.org/u/Mahrokh)\
**Post date:** [November 18, 2018, 8:59pm UTC](https://discourse.processing.org/t/how-do-i-send-variables-from-text-fields-in-processing-to-arduino/5691/1 "2018-11-18T20:59:40Z")

</div>

In my Arduino project, I’ve been sending data to the board via serial monitor in Arduino IDE.  
Here’s a part of my code from the Arduino:

```auto
`while (Serial.available() > 0) {

    // look for the next valid integer/float in the incoming serial stream:
    float voltage_1 = Serial.parseFloat(); //Voltage amplitude
    float widthF_1 = Serial.parseFloat(); //Pulse width 
    float interF_1 = Serial.parseFloat();
    int frequency_1 = Serial.parseInt (); //frequency of pulses
    int number_1 = Serial.parseInt (); //number of pulses
    int delayy_1 = Serial.parseInt (); //The delay before applying the pulse

    float voltage_2 = Serial.parseFloat(); //Voltage amplitude
    float widthF_2 = Serial.parseFloat(); //Pulse width 
    float interF_2 = Serial.parseFloat();
    int frequency_2 = Serial.parseInt (); //frequency of pulses
    int number_2 = Serial.parseInt (); //number of pulses
    int delayy_2 = Serial.parseInt (); //The delay before applying the pulse
    
    if (Serial.read() == '\n') {` // ....

```

So, basically I type 12 numbers separated by commas in the serial monitor each time I want to give an input to my board. I want to do this with Processing instead. I have put 12 text field and drawn a rectangle as a button in Processing. I want the user to be able to type the variables in those text fields and click on the button to send the data to the Arduino board. Here’s how I have set up the text fields in processing:

```auto
println("Available serial ports:");
    println(Serial.list());

    port = new Serial(this, Serial.list()[0], 9600);
    
  cp5 = new ControlP5(this);
 
  cp5.addTextfield("textInput_1").setPosition(210, 80).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_2").setPosition(210, 130).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_3").setPosition(210, 180).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_4").setPosition(210, 230).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_5").setPosition(210, 280).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_6").setPosition(210, 330).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
   
  cp5.addTextfield("textInput_7").setPosition(535, 80).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_8").setPosition(535, 130).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_9").setPosition(535, 180).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_10").setPosition(535, 230).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_11").setPosition(535, 280).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);
  cp5.addTextfield("textInput_12").setPosition(535, 330).setSize(70, 33).setAutoClear(false).setFont(f).setColor(0).setColorBackground(#f2f2f2);

```

How do I do this? It’s my first time using processing, and I have only come across few simple examples of sending data through Processing.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [November 18, 2018, 9:42pm UTC](https://discourse.processing.org/t/how-do-i-send-variables-from-text-fields-in-processing-to-arduino/5691/2 "2018-11-18T21:42:31Z")

</div>

Hi Mahrokh,

I guess you’ll find some lead over there: [Send 3 variable to arduino?](https://discourse.processing.org/t/send-3-variable-to-arduino/5467/13)
