Virtual Pin

Status
Not open for further replies.

Paul S

Active member
I am using a Teensy 3.2 on a wearable LED project. I have lights (light strips) on my arms, legs and torso (front and back). I have about 1820 lights. What I am looking for is if there is a way to use one pin to control different regions (i.e. arm, leg, torso) at the same time. Say I want to run a chase pattern on my arm and chest at the same time. I would use the "virtual" pin to run the arm (lights 1-50) and the chest (lights 600-1200). I would code to run "pin" 1 for the arm and "pin" 3 for the chest. The sketch would know that pin 1 is for the arms and pin 3 is for the chest. Any thoughts? Thanks
 
Lots of ways to tackle this one, but one would a state machine.

Basic idea is you have true/false flags for which strips you wanted to be getting data, create the effect either as a whole stored strip or pixel by pixel and have a function which did a series of if (arm==true) strip.pixel=colour; else strip.pixel=0;

Then update all strips

You can do this with lots of manually defined values, but working with some two dimensional arrays may make some parts of this easier https://www.arduino.cc/en/Reference/Array
 
Find a sample or two to understand how it works. AFAIK: Unless you have independent control lines to each string of lights they will all be fed from the one array per controlled set.

Per @GremlinWrangler - You just need to break up the array into 'virtual' segments where each represents one element Torso, L/R & Arm/Leg and then programmatically select how each of those elements is set. Given that they have different lengths a simple [5] dimensional array of equal sizes won't do that so splitting that up will take some bit of work.
 
It does strike me that 1,820 individual LEDs is a lot of LEDs. Have you priced out those LEDs? Will you blind people nearby if all of the LEDs are turned on at a time.

That many LEDs are going to need a lot of power. Have you factored into this how many batteries you are going to need, and how long do they need to be powered?

If you use APA102 (Adafruit Dotstars) or WS2812B (Adafruit Neopixels) you are getting to the point where you need complex programming such as the FastLED or Octows2811 libraries.

Instead of APA102/WS2812B LEDS, if you were to go to i2c to drive those LEDs with something like a MCP23017 (drive 16 LEDs via i2c), you would likely not be able to hook these up on a single i2c bus. If the LEDs are the individual LEDs that you buy in combo packs, have you consider how long it will take to solder all of the LEDs and their resistors?

Given your description of different zones, I suspect the best approach is to make it modular. Have one microprocessor (maybe a Teensy LC) to handle each read. I.e. one for the left arm, one for the right leg, etc. Then have them communicate with a boss microprocessor that says 'right leg do pattern #1, head do pattern #7, left arm turn off'. That way, it is much simpler to debug when something goes awry. You can probably use one battery for the processor and the lights that it controls. It also means you don't have to use complex programming like you would if you only used a single processor.

Even if you break the LEDs into several regions, I would look seriously at reducing the number of LEDs. Maybe a 100 or so.
 
Last edited:
Hey Michael,
my project already exists and I have used it. I bought the LEDs directly form the manufacturer in China. So the cost was less. I am using LED strips so I don't have to solder them all individually.
If I have them all on it is pretty bright. To remedy this I use a lower setting in my sketch. I don't use the full 255. I have had people say I was blinding them but they must have been mesmerized by the colors and couldn't look away. :)
I am running 6 batteries. 2 - 15.6 aH and 4 - 6.6 Ah I used the suit last week and the batteries lasted for the 3+ hours I was at the event. Of course using low intensity, multiple colors and various patterns helps with the life span.
I am using WS2812B lights and so far using Adafruits library. I will probably also use FastLED.
At this point, I have all of the lights wired together and have one data line continuous. I am trying to avoid more wiring because I am concerned about excessive wires and the movement of it being wearable. I am hoping that the less wires the less problems. I may consider your suggestion about multiple microprocessors but am hopeful there may be another way.
100 lights is no fun. LOL The more the better!
I am not a programmer but have learned some basics and will learn more. I also have some help at the local maker space I attend. I envision that it would be possible to encode the separate areas in one sketch. Such as defining the different regions and then sending different code to the defined regions to do separate patterns.
Here is a video of it. https://www.youtube.com/watch?v=05cc75bLuJA
Thanks for your input.
 
GremlinWrangler post 2 note on two dimensional arrays made me wonder about something like this. If you want to treat the FIVE parts as linear you can just make 5 pointers into the larger array with offsets to the starting position to edit those elements uniquely - foo1=&foo[294].

Looking at your video there are banded groups on your strips. You might want a two dimensional array pointer to leg1[20][20] that starts at full_array[294].

This example code would allow that - at least it does for a character array - note two sub pointers start at foo[0] - you would pick the start offset:
Code:
char foo[100];
char (*foo1)[10] = (char(*)[10]) &foo[0]; // this could be left arm in groups of 10
char (*foo2)[20] =(char(*)[20]) &foo[0]; // this could be left leg in groups of 20
void setup() {
  Serial.begin(57600);
  while ( !Serial ) ;
  int ii,jj;
  for ( ii=0; ii<100; ii++ ) foo[ii]='a';
  for ( ii=0; ii<100; ii++ ) Serial.print( foo[ii] );
  Serial.println(  );
  for ( ii=0; ii<10; ii++ ) for ( jj=0; jj<10; jj++ ) foo1[ii][jj]='b';
  for ( ii=0; ii<100; ii++ ) Serial.print( foo[ii] );
  Serial.println(  );
  for ( ii=0; ii<5; ii++ ) for ( jj=0; jj<20; jj++ ) foo2[ii][jj]='a';
  for ( ii=0; ii<100; ii++ ) Serial.print( foo[ii] );
  Serial.println(  );
}
loop(){}
 
Thanks Defragster. I will run this by a friend who understands these things better than me for a better understanding.
 
PaulS - cool hopefully it makes useful sense. If you post the array and count it uses and the offsets to the 'parts' in the array - and notes about how they are grouped - like a thigh might have 5 groups of 30 - of course they probably alternate directions . . . more fun.
 
Status
Not open for further replies.
Back
Top