Hey guys I have a LED strip with 6 LEDS (I control these through Kinect & processing. It sends 1,2,3,4,5,6 to Arduino. This seems to work fine.)
In Arduino LED0,LED1,LED2,LED3,LED4 work perfectly but the last one don't work. it doesn't light up at all.
Anyone know what's going on?
#include <FastLED.h>
#define LED_PIN 13
#define NUM_LEDS 6
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
int incomingByte = Serial.read();
//1
if(incomingByte=='1'){
leds[0] = CRGB(255, 0, 0);
FastLED.show();}
if(incomingByte=='2'){
leds[0] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='3'){
leds[0] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='4'){
leds[0] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='5'){
leds[0] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='6'){
leds[0] = CRGB(0, 0, 0);
FastLED.show();}
//2
if(incomingByte=='1'){
leds[1] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='2'){
leds[1] = CRGB(255, 0, 0);
FastLED.show();}
if(incomingByte=='3'){
leds[1] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='4'){
leds[1] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='5'){
leds[1] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='6'){
leds[1] = CRGB(0, 0, 0);
FastLED.show();}
//3
if(incomingByte=='1'){
leds[2] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='2'){
leds[2] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='3'){
leds[2] = CRGB(255, 0, 0);
FastLED.show();}
if(incomingByte=='4'){
leds[2] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='5'){
leds[2] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='6'){
leds[2] = CRGB(0, 0, 0);
FastLED.show();}
//4
if(incomingByte=='1'){
leds[3] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='2'){
leds[3] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='3'){
leds[3] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='4'){
leds[3] = CRGB(255, 0, 0);
FastLED.show();}
if(incomingByte=='5'){
leds[3] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='6'){
leds[3] = CRGB(0, 0, 0);
FastLED.show();}
//5
if(incomingByte=='1'){
leds[4] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='2'){
leds[4] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='3'){
leds[4] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='4'){
leds[4] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='5'){
leds[4] = CRGB(255, 0, 0);
FastLED.show();}
if(incomingByte=='6'){
leds[4] = CRGB(0, 0, 0);
FastLED.show();}
//6
if(incomingByte=='1'){
leds[5] = CRGB(0, 0, 0);
FastLED.show();
if(incomingByte=='2'){
leds[5] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='3'){
leds[5] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='4'){
leds[5] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='5'){
leds[5] = CRGB(0, 0, 0);
FastLED.show();}
if(incomingByte=='6'){
leds[5] = CRGB(255, 0, 0);
FastLED.show();}
}
}
}
here's the processing code:
float x = 100;
float y = 50;
float w = 150;
float h = 80;
import org.openkinect.freenect.*;
import org.openkinect.processing.*;
import processing.serial.*;
// The kinect stuff is happening in another class
KinectTracker tracker;
Kinect kinect;
Serial myPort;
void setup() {
size(512, 424);
kinect = new Kinect(this);
tracker = new KinectTracker();
String portName = Serial.list()[3]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);
}
void draw() {
tracker.track();
tracker.display();
PVector v1 = tracker.getPos();
fill(50, 100, 250, 200);
noStroke();
ellipse(v1.x, v1.y, 50, 50);
//1
if (v1.x > 0 && v1.x < 50 ){
println('1');
//rect(0,200,200,200);
myPort.write('1'); }
//println('0'); }
//2
if (v1.x > 50 && v1.x < 100){
println('2');
myPort.write('2'); }
//3
if (v1.x > 100 && v1.x < 150 ){
println('3');
myPort.write('3'); }
//4
if (v1.x > 150 && v1.x < 200 ){
println('4');
myPort.write('4'); }
//5
if (v1.x > 200 && v1.x < 250 ){
println('5');
myPort.write('5'); }
//6
if (v1.x > 250 && v1.x < 300 ){
println('6');
myPort.write('6'); }
}