User Tools

Site Tools

@Title Processing to Arduino RGB LED (Neopixels)
@Author Geert Roumen
@Institute Umeå Institute of Design
@Date 29-01-2018
IDE:  Processing 3.3.6
OS:   Windows 10.0.17134 Build 17134
import java.awt.*;
Robot robot;
import processing.serial.*;
Serial myPort;  
int val;       
//Setup the communication and Robot instance
void setup(){
  size(1000, 150);
  //Connect to the first Serial port of the PC
  String portName = Serial.list()[0];
  print("Serial ports: ");
  print("Chose ");
  //Try to open this port
  myPort = new Serial(this, portName, 9600);
  //If you want this window to always stay on top
  //Try to create a AWT Robot
    robot = new Robot();
  }catch (AWTException e){
    throw new RuntimeException("Unable to Initialize", e);
//Make a counter variable
int i=0;
void draw(){
  //Get the location of the pointer (mouse/cursor)
  Point mouse;
  mouse = MouseInfo.getPointerInfo().getLocation();
  //Get the color at the location of the pointer, pointer icon is ignored
  Color c = robot.getPixelColor(mouse.x,mouse.y);
  //Get the integer RGB value at this point
  int top = c.getRGB();
  //Write an S to the Serial port
  //Do some conversion to make it look white when all colors are 255
  //These values are based on neopixels.
  float r = (float) (red(top)*0.780);//(199/255));
  float g = (float) (green(top)*0.99);//;(254/255));
  float b = (float) (blue(top)*0.56);//(144/255));
  //Start writing the [RGB] as three bytes 
  myPort.write((byte) r); 
  myPort.write((byte) g); 
int j=0;
//if a key is pressed an image of the current 'flow' will be saved.
void keyPressed() {
@Title Processing to Arduino RGB LED (Neopixels)
@Author Geert Roumen
@Institute Umeå Institute of Design
@Date 29-01-2018
ESP8266   RGB Neopixel
GND       GND
D2        Input
5V/USB    Power
NodeMCU ESP8266: 
In this example sketch processing can send an RGB value to Arduino and Arduino will change the LED color of the NUMPIXELS connected neopixels
#include <Adafruit_NeoPixel.h>
//In this example I use a nodeMCU, with the LED strip connected to D2, for normal Arduino use a number for digital, A0-A5 for the analog pins 
#define PIN            D2
//The amount of pixels connected to the Arduino, make sure they are powered correctly
#define NUMPIXELS      6
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
void loop() {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  int r,r2,r3;
  int g,g2,g3;
  int b,b2,b3;
  if(Serial.available()) {   
    if( == 'S') {
      //When it finds an 'S' char, it will wait untill it finds 3 other bytes
      r =;
      g =;
      b =;
    delay(10); // some recovery time, not sure if nessecary
    for(int i=0;i<NUMPIXELS;i++){
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(r,g,b)); // Moderately bright green color.
  }; // This sends the updated pixel color to the hardware
light_experience_prototyping.txt · Last modified: 2018/10/01 14:52 by geert