Go Down

Topic: Custom LED Rave Mask Project - Near completion (Read 338 times) previous topic - next topic

willhartley

Dec 05, 2018, 05:03 am Last Edit: Dec 12, 2018, 04:01 pm by willhartley
Hello everyone, I am back again with another weird project.

I am working on a rave mask for my birthday coming up. I have the layout and everything all measured out, I also have various animations made but am having a little trouble with the mechanics of one.

Here are some pictures below to give some background on what I am trying to do. I may make this into an instructable if people are interested.

I am essentially trying to make a heartbeat animation but instead of deleting it like in the video, below, I am trying to keep how it is on a real HB sensor.

What I mean by this is; instead of turning on the array, then deleting the array one by one. How do I turn on the first array, the actual heart beat and instead, just start over and redraw it in a different position, making it seem it is a continuous line and NOT on then off, on then off.

Hopefully I am wording it right. I will upload some pictures and videos of it to give clarity, and also, my code.

Also, if any of you have any cool animations you can think of, would be greatly appreciated :D <3

I made this in photoshop but use the template and paint bucket to make the designs before animating them. See below/attached


Code: [Select]
/* Arduino 256 RGB LEDs Matrix Animation Frame
 * Using WS2812 LED Strips
 
Created by Yvan / https://Brainy-Bits.com

This code is in the public domain...

You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!

*/

//
/*  LED Matrix diagram for mask
000---001---002---003---004---005---006---007---008---009---010---011------------------ // 12
---022---021---020---019---018---017---016---015---014---013---012--------------------- // 11
------023---024---025---026---027---028---029---030---031---032------------------------ // 10
---------041---040---039---038---037---036---035---034---033--------------------------- // 9
------042---043---044---045---046---047---048---049---050---051------------------------ // 10
---------060---059---058---057---056---055---054---053---052--------------------------- // 9
------------------061---062---063---064---065---066------------------------------------ // 6
---------------------------067---068---069--------------------------------------------- // 3
*/


#include <avr/pgmspace.h>  // Needed to store stuff in Flash using PROGMEM
#include "FastLED.h"       // Fastled library to control the LEDs

// How many leds are connected?
#define NUM_LEDS 70

// Define the Data Pin
#define DATA_PIN 3  // Connected to the data pin of the first LED strip

// Define the array of leds
CRGB leds[NUM_LEDS];

int heartbeat [] = {42, 43, 44, 39, 26, 18, 5, 27, 46, 63, 56, 47, 36, 35, 34, 33}; //array with the LED adresses to light up
int beat_line [] = {42, 43, 44, 45, 46, 47, 48, 49, 50, 51}; //10 in row line that i was going to ue as static line before beats

void setup() {
//FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS);  // Init of the Fastled library
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(25);
}

void loop() {

//FastLED.clear();
for(int i = 0; i < 16; i++) {
    leds[heartbeat[i]] = CRGB::Red;
    FastLED.show();
    delay(28);
  }

for(int i = 0; i < 16; i++) {
    leds[heartbeat[i]] = CRGB::Black; //turn them off
    FastLED.show();
    delay(28);
  }
//FastLED.show();
delay(500);
}


What it should look like



Layout of leds



Layout of mask


Video of what I have so far
Click for video

willhartley

Another thing I thought of, if I just draw the pattern out double the arrays and shift it right to give the appearance of a solid line and animation?

I'm not sure how to shift the pattern though. I'll have to check some example code

lesept

Your leds are numbered like this:


And the line is displayed when these leds are on
Code: [Select]
int beat_line [] = {42, 43, 44, 45, 46, 47, 48, 49, 50, 51};


The heartbeat is when these leds are on:
Code: [Select]
int heartbeat [] = {42, 43, 44, 39, 26, 18, 5, 27, 46, 63, 56, 47, 36, 35, 34, 33}


If you want to display as if the HB peak was going from left to right, you'll have 2 problems:
  • The end line of the HB is not at the same level as the beginning line (36-33 is higher than 42-44)
  • When the rising edge reaches the left side of your array (after 44 is shifted to 42), the next step will make the beginning of the rising edge disappear, you'll only have a part of it displayed.


So maybe you should put the end line at the same level as the beginning line (i.e. 48-51 instead of 36-33).
Code: [Select]
int heartbeat [] = {42, 43, 44, 39, 26, 18, 5, 27, 46, 63, 56, 47, 48, 49, 50, 51}


For the animation, the simplest is to define other arrays to lit the leds according to the movement of the HB signal. Example, for one step to the left:
Code: [Select]
int heartbeatMinus1 [] = {42, 43, 40, 25, 19, 4, 26, 45, 62, 57, 46, 47, 48, 49, 50, 51}
And so on...

Then to run the animation:
Code: [Select]
void loop() {

FastLED.clear();
for(int i = 0; i < 16; i++) {
    leds[heartbeat[i]] = CRGB::Red;
    FastLED.show();
    delay(28);
  }

FastLED.clear();
for(int i = 0; i < 16; i++) {
    leds[heartbeatMinus1[i]] = CRGB::Red;
    FastLED.show();
    delay(28);
  }

FastLED.clear();
for(int i = 0; i < 16; i++) {
    leds[heartbeatMinus2[i]] = CRGB::Red;
    FastLED.show();
    delay(28);
  }

etc...
}

For a better looking code, you should define 2D arrays and do the animation with loops.
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

willhartley

Your leds are numbered like this:
Definitely giving you some karma for your assistance. You did more than I though and I appreciate the help.

I am beginning to understand a bit more where I need to get to.

Right now I am thinking:

1: Move static line to [42-51]

When the rising edge reaches the left side of your array (after 44 is shifted to 42), the next step will make the beginning of the rising edge disappear, you'll only have a part of it displayed.
2:Limit the movement of the "beat minimum led" to led row/range [62-65] to keep in bounds

3:Create multiple arrays with the different animations like you suggested. I will need 4 and maybe will select them at random to give it a more natural look.

I will test this later but for now Im stuck at work so I will probably try to make it into a few pictures using your template and use a gif maker to see how it runs.

willhartley

Ok so, it looks like I kind of spliced it together in gif format. I am pretty bored here at work.

I think what I will do, is make four arrays , or an array that holds all the values. Then alterenate between the 4 beats.

such as, beat1, beat2, beat3, beat4. I think I will go with a simple randomizer so that way the patterns arent sequential but in a random order -- 1,3,2,4 ... 3,2,4,1 ... etc

Will look alot better on the LEDs itself, I promise lol


lesept

A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

willhartley

Video of what I have so far
Click for video
Ok so I ran the animation last night for the first time and I am still deciding on if i like it. The problem with the new animation, as you can see in the gif, the left side first few leds never move. They are constantly lit which does not give it a sense of motion.

One thing I changed, is I did add a colorpalette in to change the way it looks on the fly, well color wise and I also went back to the original animation.

What I did differently though, is just kept the other animations and just have them run in different orders and also maybe flipped. This way it will give the sense of multiple animations running in different spots.


Slumpert

Wonder if you "treated" your mask as a full 12x8 matrix, you could setup an array and check position in the array to see if there is a "actual" LED to write to data too or not.






willhartley

Wonder if you "treated" your mask as a full 12x8 matrix, you could setup an array and check position in the array to see if there is a "actual" LED to write to data too or not.

So, I've seen this done on various forum posts but have been unable to find adequate examples. I tend to look at lots of code to learn and compare before coming here.

If you can point me in the right direction, I can give it a go.

As of last night, I added the push button and have edited the code to cycle through animations. I will post full code and pictures this weekend once I get the LEDs glued to the felt.


Side note: I am uber excited to test this out and wear it. I found this idea from this video.

willhartley

Here's an update to anyone following.

I was able to make the project mobile now. will upload more animations and then my code.

Will keep this updated in case people are interested in giving the project an attempt.



New video of the project here.





Go Up