Jump to content
  • 0

gech

Question

Here is a little project wich can drive ws2812 ledstrip with an arduino plugged into a pinscape controller used as a ledwiz (so it should work with a reel ledwiz)

This is not a ledwiz clone but a collection of effects : contactors, fan, beacon, gear, lauch button, strobe..

This is a work in progress so...

The arduino is plugged on a ledwiz clone : the pinscape controller (kl25z) 

The pinscape controller drives 3 rgb leds and 2 strobes.

I tried with a Uno and a Mega and both are working well.

 

Video

 

 

and code

#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel Stick = Adafruit_NeoPixel(288, 22, NEO_GRB + NEO_KHZ800);
        int d = Stick.numPixels();
        int slingshot = 25;
        int part = d/16;
        int speed = 30;
        int length = 90;
        int limite1 = 25;
        int limite2 = d-25;
        int launch = 25;
void setup() {

//    Serial.begin(9600);
        pinMode(2, INPUT_PULLUP);
        pinMode(3, INPUT_PULLUP);
        pinMode(4, INPUT_PULLUP);
        pinMode(5, INPUT_PULLUP);
        pinMode(6, INPUT_PULLUP);
        pinMode(7, INPUT_PULLUP);
        pinMode(8, INPUT_PULLUP);
        pinMode(9, INPUT_PULLUP);
        pinMode(10, INPUT_PULLUP);
        pinMode(11, INPUT_PULLUP);
        pinMode(12, INPUT_PULLUP);
        pinMode(13, INPUT_PULLUP);
              
    // Initialize all the pixelStrips
    Stick.begin();
        // Kick off a pattern
    Stick.Color(0,0,0);
    Stick.show();
}

void loop() {
for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs
    Stick.show();

    // Switch patterns on a button press:
    if (digitalRead(2) == HIGH) // Slingshot Left Button #14 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs
        // Set stick to all red
  for (int i=limite1; i<limite1+slingshot; i++)
  {
        Stick.setPixelColor(i,Stick.Color(255,0,0));
    }
    Stick.show();
    }
    else if (digitalRead(3) == HIGH) // Slingshot Right Button #15 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all blue
  for (int i=limite2; i>limite2 - slingshot; i--)
  {  
        Stick.setPixelColor(i,Stick.Color(0,0,255));
    }
    Stick.show();
    }
    else if (digitalRead(4) == HIGH) // Launch Button #16 pressed
    {
        // Set stick to Launch Blue
    for (int i=limite2 - launch; i<limite2; i++)
    {
  for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs
      Stick.setPixelColor(i, (0, 0, 255));  // Set just this one
      Stick.show();
      delay(5);
    }
    }
    else if (digitalRead(5) == HIGH) // Gear Button #17 pressed
    {
       for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all pink
        int foo = random(d);
  Stick.setPixelColor(foo, 255,255,255); // Set pixel white
  Stick.show(); // Update strip to show new pixel
  delay(10); // Hold it for a moment
  Stick.setPixelColor(foo, 0, 0, 0); // Pixel off
  //Stick.Color1 = Stick.Wheel(random(255));
  // Change will be reflected on next strip.show()


  
    }
    else if (digitalRead(6) == HIGH) // Beacon Button #18 pressed
    {

      
         for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }

    for(int i=limite1; i<length; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,255)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(speed);

    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    
    for(int i=limite2; i>limite2 - length; i--) {
        Stick.setPixelColor(i, Stick.Color(255,0,0)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(speed);
    
    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    
    for(int i=limite1 + length; i<limite2 - length ; i++) {
        Stick.setPixelColor(i, Stick.Color(255,255,255)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(speed);

    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }

    for(int i=limite1; i<limite1 + length; i++) {
        Stick.setPixelColor(i, Stick.Color(255,0,0)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(speed);

    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    
    for(int i=limite2; i>limite2 - length ; i--) {
        Stick.setPixelColor(i, Stick.Color(0,0,255)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(speed);
    
    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    
    for(int i=limite1 + length; i<limite2 - length; i++) {
        Stick.setPixelColor(i, Stick.Color(255,255,255)); // light 'em up
    }
    Stick.show(); // show 'em    
    delay(speed/2);
}
    else if (digitalRead(7) == HIGH) // Strobe right Button #20 pressed
    {
        // Set stick to all white
 for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    Stick.show(); // show 'em    
    delay(speed);
    
    for(int i=limite1; i<limite2; i++) {
        Stick.setPixelColor(i, Stick.Color(255,255,255)); // light 'em up
    }
    Stick.show(); // show 'em    
    delay(speed);
    }
    else if (digitalRead(8) == HIGH) // Bumper Back Right Button #21 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all green
  for (int i=d-(4*part); i>(9*part); i--)
  {
        Stick.setPixelColor(i,Stick.Color(0,255,0));
    }
    Stick.show();
    }
    else if (digitalRead(9) == HIGH) // Bumper Back Center Button #22 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all blue
  for (int i=d-(7*part); i>(7*part); i--)
  {
        Stick.setPixelColor(i,Stick.Color(0,0,255));
    }
    Stick.show();
    }
    else if (digitalRead(10) == HIGH) // Bumper Back Left Button #23 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all red
    for (int i=(4*part); i<(7*part); i++)
  {
        Stick.setPixelColor(i,Stick.Color(255,0,0));
    }
    Stick.show();
    }
    else if (digitalRead(11) == HIGH) // Bumper Middle Right Button #24 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all ???
    for (int i=d-(1*part); i>d-(4*part); i--)
  {
        Stick.setPixelColor(i,Stick.Color(0,255,255));
    }
    Stick.show();
    }
    else if (digitalRead(12) == HIGH) // Bumper Middle Center Button #25 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all ???
    for (int i=d-(2*part); i>d-(5*part); i--)
      {
        Stick.setPixelColor(i,Stick.Color(255,0,125));
    }
    for (int i=(2*part); i<(5*part); i++)
      {
        Stick.setPixelColor(i,Stick.Color(255,0,125));
    }
    Stick.show();
    }
    else if (digitalRead(13) == HIGH) // Bumper Middle Left Button #26 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all ???
    for (int i=part; i<(2*part); i++)
      {    
        Stick.setPixelColor(i,Stick.Color(200,25,0));
    }
    Stick.show();
    }
    else if (digitalRead(30) == HIGH) // ZB launch button Button #27 pressed
    {
        // Set stick to Launch Blue
    for (int i=limite2 - launch; i<limite2; i++)
    {
  for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs
      Stick.setPixelColor(i, (255, 0, 0));  // Set just this one
      Stick.show();
      delay(5);
    }
    }
    else if (digitalRead(31) == HIGH) // Authentic launch ball Button #28 pressed
    {
        // Set stick to Launch Blue
    for (int i=limite2 - launch; i<limite2; i++)
    {
  for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs
      Stick.setPixelColor(i, (100, 0, 155));  // Set just this one
      Stick.show();
      delay(5);
    }
    }
    else if (digitalRead(32) == HIGH) // Fan #29 pressed
    
    {
        // Set stick to Launch Blue
  for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs
    for (int i=limite1; i<d/2; i++)
    {
      Stick.setPixelColor(i, (0, 0, 255));  // Set just this one
      Stick.setPixelColor(d-i, (0, 0, 255));  // Set just this one
      
      Stick.show();
      delay(5);
    }
    for (int i=d/2; i>limite1 ; i--)
    {
      Stick.setPixelColor(i, (0, 0, 0));  // Set just this one
      Stick.setPixelColor(d-i, (0, 0, 0));  // Set just this one
      
      Stick.show();
      delay(5);
    }
    
    }
    else if (digitalRead(33) == HIGH) // Shacker Button #30 pressed
    {
        for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }

    for(int i=limite1; i<limite1 + 2*part; i++) {
        Stick.setPixelColor(i, Stick.Color(100,0,200)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(2*speed);

    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    
    for(int i=limite2; i>limite2 - 2*part; i--) {
        Stick.setPixelColor(i, Stick.Color(100,0,200)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(2*speed);
    
        for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }

    for(int i=limite1 + 2*part; i<limite1 + 4*part; i++) {
        Stick.setPixelColor(i, Stick.Color(200,0,100)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(2*speed);

    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    
    for(int i=limite2 - 2*part; i>limite2 - 4*part; i--) {
        Stick.setPixelColor(i, Stick.Color(200,0,100)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(2*speed);
    
        for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }

    for(int i=limite1 + 4*part; i<limite1 + 6*part; i++) {
        Stick.setPixelColor(i, Stick.Color(100,0,200)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(2*speed);

    for(int i=0; i<d; i++) {
        Stick.setPixelColor(i, Stick.Color(0,0,0)); // set 'em dark
    }
    
    for(int i=limite2 - 4*part; i>limite2 - 6*part; i--) {
        Stick.setPixelColor(i, Stick.Color(100,0,200)); // light 'em up
    }
    Stick.show(); // show 'em
    delay(2*speed);
    }
    else if (digitalRead(34) == HIGH) // Bumper Middle Left Button #31 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all ???
    for (int i=part; i<(4*part); i++)
      {    
        Stick.setPixelColor(i,Stick.Color(0,255,255));
    }
    Stick.show();
    }
    else if (digitalRead(35) == HIGH) // Bumper Middle Left Button #32 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all ???
    for (int i=part; i<(2*part); i++)
      {    
        Stick.setPixelColor(i,Stick.Color(0,255,255));
    }
    Stick.show();
    }
    else if (digitalRead(36) == HIGH) // Bumper Middle Left Button #13 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all ???
    for (int i=part; i<(2*part); i++)
      {    
        Stick.setPixelColor(i,Stick.Color(0,55,200));
    }
    Stick.show();
    }
    else if (digitalRead(37) == HIGH) // Bumper Middle Left Button #12 pressed
    {
        for (int i=0; i<d; i++)
  {
    Stick.setPixelColor(i, 0);
  }  // Turn off all LEDs 
        // Set stick to all ???
    for (int i=part; i<(2*part); i++)
      {    
        Stick.setPixelColor(i,Stick.Color(255,55,0));
    }
    Stick.show();
    }    
}

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

My situation is as follow: i'm going to setup my installation following the manual for the Pinscape Controlloer based on the Kl25Z from Mike R (https://developer.mbed.org/users/mjr/code/Pinscape_Controller/). At the same time i want to use your solution as a first step to control those ledstrips and a lightbar. A few questiosn i am having right now:

- How have you connected the arduino to KL25Z?

- How are you controlling the ledstrips AND the lightbar? All from the Arduino?

- Could i add a second Arduino for other light-effects such as strobes?

 

(I'm going to ask my questions about the toyduino here and not in the adressable-leds-topic to keep that oither topic clear ;)  )

Link to comment
Share on other sites

I am using a 32 outputs firmware for the kl25z as i don't need so much buttons and prefere the ledwiz function.

I have connected the arduino directly from the ledwiz output of the kl25z to the inputs of the arduino.

when a input is involved, an effect is launched. which means that the colors of the effects are not changing with tables.

I first used a uno and it works well but now i use a mega because of the number of I/O.. I wanted to have a lot of toys together.

what kind of arduinos do you have?

 

the lightbar is controlled by the kl25z on the ledwiz side and are connected through uln2803a which are driving the 12v (the lightbar is made of classic ledstips).

 

you can add as many arduinos as you want  ;) now that we can use TLC5940NT with the latest firm of the kl. that chip is made for multiplex the outputs of the kl25z and can be daisy chained  :wub:

my strobe output of the kl25 is making the whole leds to light up in white. the strobes placed as on my "lighbar" are useless now.

So as for the beacon.

Link to comment
Share on other sites

Hello gech. Is this the same solution as discussed previously in this topic: http://www.pincabpassion.net/t2365p105-mode-ledwiz-evoluee-sur-carte-arduino?I've read that topic also from start to finish but if i can ask questions about it in English is far easier for me  :)

 

BTW, that KL25Z/Arduino solution is looking good! I'm going to start with that in the next weeks because i already have the hardware in house.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...