import processing.serial.*;// import the serial library int r =125; int g =125; int b =125 ; int rold,gold,bold; // define all variables String oldout; Serial port; // create the serial object int count=0; void setup() { println(Serial.list()); // prints out the serial ports available port = new Serial(this,Serial.list()[1],9600);// change to correct com port(1) which is displayed by the previous line size(200,200); // size of the window background(200); // color of the backround smooth(); // makes the lines smooth frameRate(10); // change this to get better but slower results } // frame rate is normally 60/sec but thats too fast void draw() { int row = 1; background(200); // clear the display fill(r,g,b); // set the color to the mixed color rect(50,25,100,50); // box for the mixed color fill(255); for(int j=120; j<=200 ;j=j+40)// for loop to create the row of buttons { for(int i=25;i<=175;i=i+55)//for loop to create the column of buttons { rect(i,j,40,30); if(row%2 !=0) // if odd numbered row { line(i+10,j+20,i+20,j+10);// arrow up line(i+20,j+10,i+30,j+20); } else //if an even numbered row { line(i+10,j+10,i+20,j+20);// arrow down line(i+20,j+20,i+30,j+10); } } row++; // increment row }// 40 wide, 10 gap // reminded as to what the button sizes were // Text areas PFont font; font = loadFont("AngsanaNew-25.vlw"); // import the font(tools->create) textFont(font); // just copy the file name into the blue part fill(255,0,0); //text colour to red String s = nf(r,3); // nf turns an int into a string with 3 numbers before the decimal point text(s, 30, 100, 40, 20); // print the current level of red on the screen fill(0,255,0); // text colour to green String t = nf(g,3); text(t,85,100,40,20); // print the current level of red on the screen fill(0,0,255); // text colur to blue String u =nf(b,3); text(u,140,100,40,30); // print the current level of red on the screen //User input if(mousePressed) // if any button is pressed { if((mouseX> 25 )&& (mouseX< 65)) // if the button is in the first column { if((mouseY>120 )&&(mouseY<150)) // if the top button { if(r>=255) // if the value greater than 255, set to 255(8 bits), r=255; else r++; } if((mouseY>160 )&&(mouseY<190)) // if the bottom button { if(r<=0) // if less than 0, set to 0(nothing) r=0; else r--; } } if((mouseX> 80 )&& (mouseX< 120)) // if the button is in the first column { if((mouseY>120 )&&(mouseY<150)) // if the top buttom { if(g>=255) // if the value greater than 255, set to 255(8bit), g=255; else g++; } if((mouseY>160 )&&(mouseY<190)) // if the bottom button { if(g<=0) // if less than 0, set to 0(nothing) g=0; else g--; } } if((mouseX> 135 )&& (mouseX< 175)) // if the button is in the first column { if((mouseY>120 )&&(mouseY<150)) // if the top buttom { if(b>=255) // if the value greater than 255, set to 255(8bit), b=255; else b++; } if((mouseY>160 )&&(mouseY<190)) // if the bottom button { if(b<=0) // if less than 0, set to 0(nothing) b=0; else b--; } } } // String f = "here";// debugger // println(f); String out = nf(r,3)+ nf(g,3)+ nf(b,3);//creates the string that we will send to the Arduino //if (count%5==0) //if you want, you can only send ever xth output, just uncomment //{ println(out); // print that string to the serial monitor port.write(out); // send that string to the serial port //} //count++; }