/* Code sourced from Israa Rabba * http://fab.academany.org/2018/labs/fablabirbid/students/israa-rabbaa/INTERFACE.html ----------------------- modified by Darshan Shah, during Fab Academy 2018. */ import controlP5.*; // import controlP5 library import processing.serial.*; // import serial library ControlP5 cp5; // define cp5 as a ControlP5 object Serial myPort; // define myPort as a Serial object PFont ButtonFont; void setup(){ // create display window size(650,650); // define size cp5= new ControlP5(this); // create new object ButtonFont =createFont("Georgia",20); // define font type cp5.addButton("BROWN") // create Brown button .setPosition(215,100) // position of button .setSize(95,95) // define size of button .setFont(ButtonFont) // font type for button .setColorCaptionLabel(color(139,69,19)); // font color for the button // follow the same commands for respective color codes cp5.addButton("PINK") .setPosition(350,100) .setSize(95,95) .setFont(ButtonFont) .setColorCaptionLabel(color(255,20,147)); cp5.addButton("YELLOW") .setPosition(215,300) .setSize(95,95) .setFont(ButtonFont) .setColorCaptionLabel(color(255,255,0)); cp5.addButton("ORANGE") .setPosition(350,200) .setSize(95,95) .setFont(ButtonFont) .setColorCaptionLabel(color(255,165,0)); cp5.addButton("RED") .setPosition(215,200) .setSize(95,95) .setFont(ButtonFont) .setColorCaptionLabel(color(255,0,0)); cp5.addButton("GREEN") .setPosition(350,300) .setSize(95,95) .setFont(ButtonFont) .setColorCaptionLabel(color(0,255,0)); cp5.addButton("BLUE") .setPosition(215,400) .setSize(95,95) .setFont(ButtonFont) .setColorCaptionLabel(color(0,0,255)); cp5.addButton("AQUA") .setPosition(350,400) .setSize(95,95) .setFont(ButtonFont) .setColorCaptionLabel(color(127,255,212)); cp5.addButton("OFF") .setPosition(282,500) .setSize(95,95) .setFont(ButtonFont); myPort = new Serial(this, "COM9",9600); // connect myPort to COM9 } void draw(){ // draw title text background(224,255,255); //set background color fill(0); // set fill textSize(30); // text size text("RGB LED CONTROL", 190,50); // wirte the title and position } void RED(){ myPort.write('r'); // when RED pressed, send 'r' to serial port and when arduino receives 'r', RED color will light up // follow the same commands for respective color characters to be sent } void BROWN(){ myPort.write('w'); } void PINK(){ myPort.write('p'); } void YELLOW(){ myPort.write('y'); } void ORANGE(){ myPort.write('e'); } void GREEN(){ myPort.write('g'); } void BLUE(){ myPort.write('b'); } void AQUA(){ myPort.write('a'); } void OFF(){ // to switch off the LED myPort.write('o'); }