We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm working on a Processing sketch that will control the color of an LED strip.
Before I that sketch, I uploaded this Arduino sketch to test the LED strip:
// color swirl! connect an RGB LED to the PWM pins as indicated
// in the #defines
// public domain, enjoy!
#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3
#define FADESPEED 5     // make this higher to slow down
void setup() {
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);
}
void loop() {
  int r, g, b;
  // fade from blue to violet
  for (r = 0; r < 256; r++) { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 
  // fade from violet to red
  for (b = 255; b > 0; b--) { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  } 
  // fade from red to yellow
  for (g = 0; g < 256; g++) { 
    analogWrite(GREENPIN, g);
    delay(FADESPEED);
  } 
  // fade from yellow to green
  for (r = 255; r > 0; r--) { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 
  // fade from green to teal
  for (b = 0; b < 256; b++) { 
    analogWrite(BLUEPIN, b);
    delay(FADESPEED);
  } 
  // fade from teal to blue
  for (g = 255; g > 0; g--) { 
    analogWrite(GREENPIN, g);
    delay(FADESPEED);
  } 
}
This works great. However, when I try to run this Processing sketch, the Arduino sketch above still seems to be running
Processing sketch to control light color via a GUI:
import controlP5.*;
import processing.serial.*;
import cc.arduino.*;
ControlP5 cp5;
RadioButton r1, r2;
int bgColor = color(0,0,0);
Arduino arduino;
int GREENPIN = 5;
int REDPIN = 6;
int BLUEPIN = 3;
void setup() {
  size(700,400);
  noStroke();
  cp5 = new ControlP5(this);
  println(Arduino.list());
  //// Set up Arduino and pin output modes
  arduino = new Arduino(this, Arduino.list()[1], 57600);
  arduino.pinMode(REDPIN, Arduino.OUTPUT);
  arduino.pinMode(GREENPIN, Arduino.OUTPUT);
  arduino.pinMode(BLUEPIN, Arduino.OUTPUT);
  //All the LEDs should be off at start
  arduino.analogWrite(REDPIN, 0);
  arduino.analogWrite(GREENPIN, 0);
  arduino.analogWrite(BLUEPIN, 0);
  //GUI
    r1 = cp5.addRadioButton("radioButton")
         .setPosition(100,180)
         .setSize(40,20)
         .setColorForeground(color(120))
         .setColorActive(color(255))
         .setColorLabel(color(255))
         .setItemsPerRow(2)
         .setSpacingColumn(50)
         .addItem("Healthy",1)
         .addItem("Failing",2)
         ;
     for(Toggle t:r1.getItems()) {
       t.getCaptionLabel().setColorBackground(color(255,80));
       t.getCaptionLabel().getStyle().moveMargin(-7,0,0,-3);
       t.getCaptionLabel().getStyle().movePadding(7,0,0,3);
       t.getCaptionLabel().getStyle().backgroundWidth = 45;
       t.getCaptionLabel().getStyle().backgroundHeight = 13;
     }
void draw() {
  background(bgColor);
}
void radioButton(int a) {
  println("a radio Button event: "+a);
  changeColors();
}
void changeColors(){
  println("TEST");
  arduino.analogWrite(REDPIN, 255);
  //arduino.analogWrite(GREENPIN, 255);
  //arduino.analogWrite(BLUEPIN, 255); 
}
So, even after I run the Processing sketch, the original behavior of the Arduino sketch is still executed (changing colors), but not the Processing sketch (changing the color based on a toggle button event).
Anyone know why I can apparently upload to the Arduino, but not communicate with it via Processing?
Answers
I think you need to have the standard Firmata sketch running on your Arduino. Take a look at this reference: https://adestefawp.wordpress.com/learning/using-arduino-firmata-and-processing-together/
From the Arduino IDE select examples->firmata->standard firmata then upload this to your Arduino board.