How Do I Test An Output of Strings For a Certain Character That Shows Up Several Times In A Row

Hi, I'm fairly new to processing and programming in general. I have an Arduino that is sending numbers from 0 to about 20000 to processing. I am using a program that loops a println of a string that reads and updates the input from the Arduino.

void draw() { while (myPort.available() > 0) { String inBuffer = myPort.readString(); if (inBuffer != null) { println(inBuffer); }

This will continually print numbers based on the input from the Arduino, inBuffer being string that changes with the Arduino output. What I want to do is have the program look to see if the numbers 0 or 1 appear twice in a row and if they do, trigger one set of code, otherwise trigger another set of code.


  • if (inBuffer != null) { 
    if (inBuffer.indexOf("11")>-1) {
    // do A
    else if  (inBuffer.indexOf("00")>-1) {
    // do B
    else {
    // do C
    } // else
    } // if 
Sign In or Register to comment.