Serial Communication with Processing and Arduino

Processing and Arduino work well together, especially if you need to communicate to your computer using an Arduino.  Processing is a programming language and it’s IDE was used as a model for the Arduino IDE.

The semblance of the two makes them a good fit, as you will see in the video.  This is video is pulled from the Arduino Course for Absolute Beginners.

This video describes:

  • How to use Processing to communicate from your Arduino to your Computer

installing Arduino libraries

Installing Arduino Libraries | Beginners Guide

IoT sewage project

Pumping poo! An IoT sewage project

ESP32 webOTA updates

How to update ESP32 firmware using web OTA [Guide + Code]

error message Brackets Thumbnail V1

expected declaration before ‘}’ token [SOLVED]

Compilation SOLVED | 1

Compilation error: expected ‘;’ before [SOLVED]

Learn how to structure your code

4 Comments

  1. Anna Davydova on May 2, 2015 at 5:36 am

    Hello Michael!
    I am new to Arduino and I need some help with communication between Arduino and Processing. I’ve tried to repeat everything that you told in this tutorial, but something was going wrong.

    Could you tell me please where is my mistake?
    I’ve attached printscreen and photo.

    Thank you in advance!

    • MICHAEL JAMES on May 2, 2015 at 8:54 pm

      Hi Anna, I am unable to see the screen shot. Maybe it didn’t attach?

      • Anna Davydova on May 8, 2015 at 5:17 am

        I found my mistake! Evrything works good! Thanks for your video.) Now I’m trying to use another kind of button that works with GVS ribbon cable, http://static12.insales.ru/images/products/1/8155/27508699/troyka-button.2.jpg. But It doesn’t work. I use the scheme with multiple buttons and 1 pin. Everything works fine with 4-pin pushbutton. But how to repit the same with this kind of button?
        Here is the code:
        #define ERROR_WINDOW 50 // +/- this value
        #define BUTTONDELAY 20
        #define DEBUG_ON

        int analogPin = 3; // switch circuit input connected to analog pin 3
        long buttonLastChecked = 0; // variable to limit the button getting checked every cycle

        void setup () {
        Serial.begin(9600);
        pinMode(A3, INPUT);
        }

        void loop()
        {
        if( buttonLastChecked == 0 ) // see if this is the first time checking the buttons
        buttonLastChecked = millis()+BUTTONDELAY; // force a check this cycle
        if( millis() – buttonLastChecked > BUTTONDELAY ) { // make sure a reasonable delay passed
        if( int buttNum = buttonPushed(analogPin) ) {
        Serial.print(“Button “); Serial.print(buttNum); Serial.println(” was pushed.”);
        }
        buttonLastChecked = millis(); // reset the lastChecked value
        }
        }

        int buttonPushed(int pinNum) {
        int val = 0; // variable to store the read value
        digitalWrite((14+pinNum), HIGH); // enable the 20k internal pullup
        val = analogRead(pinNum); // read the input pin

        // we don’t use the upper position because that is the same as the
        // all-open switch value when the internal 20K ohm pullup is enabled.
        //if( val >= 923 and val = 475 and val = (375-ERROR_WINDOW) and val = (275-ERROR_WINDOW) and val = (175-ERROR_WINDOW) and val <= (175+ERROR_WINDOW) ) { // 230
        #ifdef DEBUG_ON
        Serial.println("switch 4 pressed/triggered");
        #endif
        return 4;
        }

        else
        return 0; // no button found to have been pushed
        }

        http://lh3.ggpht.com/_PwqQjVZfo_A/S4PjXq0R8VI/AAAAAAAAANs/sl00mmBM_5Q/Analogebuttons_Series_bb.jpg

        • MICHAEL JAMES on May 8, 2015 at 9:34 pm

          Awesome! It’s always a great feeling when things work out. Good luck on the next part!

Leave a Comment