Strike LED

front_page_0.JPG

I created this software using Processing software. If the selector is set in red, then the software sends values from 0 to 79, depending upon how much brightness is selected, to Serial port. For green, data value ranges from 80 to 159. For blue, it is 160 to 239. Arduino decodes the values and controlls the RGB LED (common anode). Please help me put up the software directly on Internet so that you and others can use it.

The Arduino code is:

#define rled 9 #define gled 10 #define bled 11 int rBrightness; int gBrightness; int bBrightness; int x; void setup() { pinMode(rled,OUTPUT); pinMode(gled,OUTPUT); pinMode(bled,OUTPUT); Serial.begin(9600); } void loop() { if(Serial.available()) { x=Serial.read(); } if((x>=0)&&(x<=79)) { rBrightness=x*3; } else if((x>=80)&&(x<=159)) { gBrightness=(x-80)*3; } else if((x>=160)&&(x<=239)) { bBrightness=(x-160)*3; } analogWrite(rled,255-rBrightness); analogWrite(gled,255-gBrightness); analogWrite(bled,255-bBrightness); }

The Processing Code is:

import processing.serial.*; Serial port; int r=0; int g=0; int b=0; int rp=30; int gp=30; int bp=30; int selectorY=49; boolean pkeyPressed; void setup() { size(345,200); port=new Serial(this,Serial.list()[1],9600);//Change the number inside [] to the intended serial port number println("Available Ports:"); println(Serial.list()); } void draw() { background(0); fill(255,0,0); triangle(20,49,275,47,275,51); fill(0,255,0); triangle(20,99,275,97,275,101); fill(0,0,255); triangle(20,149,275,147,275,151); if((keyPressed)&&(key==CODED)) { if(selectorY==49) { if((keyCode==RIGHT)&&(r<79)) { r++; } if((keyCode==RIGHT)&&(rp<269)) { rp+=3; } if((keyCode==LEFT)&&(r>0)) { r--; } if((keyCode==LEFT)&&(rp>30)) { rp-=3; } } if(selectorY==99) { if((keyCode==RIGHT)&&(g<79)) { g++; } if((keyCode==RIGHT)&&(gp<269)) { gp+=3; } if((keyCode==LEFT)&&(g>0)) { g--; } if((keyCode==LEFT)&&(gp>30)) { gp-=3; } } if(selectorY==149) { if((keyCode==RIGHT)&&(b<79)) { b++; } if((keyCode==RIGHT)&&(bp<269)) { bp+=3; } if((keyCode==LEFT)&&(b>0)) { b--; } if((keyCode==LEFT)&&(bp>30)) { bp-=3; } } if((keyCode==DOWN)&&(selectorY<149)&&(pkeyPressed==false)) { selectorY+=50; pkeyPressed=true; } if((keyCode==UP)&&(selectorY>49)&&(pkeyPressed==false)) { selectorY-=50; pkeyPressed=true; } } else { pkeyPressed=false; } noStroke(); fill(255,255,0,255); ellipse(310,selectorY,20,20); fill(255,0,0); ellipse(rp,49,14,14); fill(0,255,0); ellipse(gp,99,14,14); fill(0,0,255); ellipse(bp,149,14,14); if(selectorY==49) { port.write(r); } if(selectorY==99) { port.write(g+80); } if(selectorY==149) { port.write(b+160); } }

https://www.youtube.com/watch?v=dwKiFpwhvbw

You can use dropbox to post

You can use dropbox to post the files, and you can even put them in zip attached here on the post.

Regarding the code please

Regarding the code please read this in order to improve this post readability. Looking at code formatted as it is, or in this case completely bereft of any formatting whatsoever is almost as bad as trying to make sense out of letters soup!

As for file sharing, you can just follow beetie’s suggestion, either use the attachment feature on the edit post section, or alternatively you can host your files in any cloud free sharing services, there’s quite a few of them, dropbox being one of the most common and easy to use.

confusion

Serial(this,Serial.list()[1],9600);

while running the program, in the above mentioned line of your code, i see an error occuring as "ArrayIndexOutOfBoundsException:1

please help