Flex Sensor and Mini 8X8 LED Matrix????

Completely new to Arduino-I just received my components listed in the title and below:
8X8 Mini LED Matrix, Flex Sensor, Arduino Uno, MAX7219 and perma-proto 1/4 Sized BreadBoard (3)

I am hoping to rig this project such that the flex sensor can act both as the switch for the matrix and the dimmer...
Bent=Off Straight=Full power
I have watched various videos and read tutorials on both functions-wiring the matrix with the MAX, and the flex sensor
working with only one LED but bringing them both together as one project is what i want to do.

I am an Industrial Design Student trying to incorporate all of this within a task light I have made.
Any and all help would be appreciated.

Is this possible?
What other parts do I need other than resistors? Are my breadboards too small?
Can the flex sensor and matrix be on separate breadboards with distance between them?

I don't know code or really anything when it comes to this-just what I have read/watched.
I am also new to wiring so the right amount of voltage/resistance is something I cannot do myself.
Thank you again for any and all help...

Yes, that will be easy to do.
Obtain a 0.1uF and a 1uF cap also for the MAX7219.
Wire up the matrix and the display per the MAX7219 datasheet to start.
http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf
Seg0-7 go to the Anode pins, and Dig0-7 go to the Common Cathode pins.

The current [I<sub>SET</sub>] for the LEDs, vis-a-vis the MAX7219, is established by RSET. There is a value below which that should not go (too much current). I don't know what the range of a flexsensor is, but I think that you may not want to substitute it directly for RSET.
Maybe the better way would be to use the flexsensor with analogRead and result a variable RSET that way.
As this is for a "task light" then perhaps the "7219" may not be necessary. Do you require just an arrangement of LEDs to vary (dim as a whole) or is the arrangement required to do patterns and so on? If you need just to vary the lot, it'd be easy to read the flexsensor (analogRead) and result a PWM result (analogWrite) for the LEDs based on that.

Do one thing at a time.

Learn how the flex sensor works, and implement it.

Learn how the led works, and implement.

And then try and combine the two.

Thank you SO much. Yes all I need is for the matrix to dim as a whole. I can/am open to buying a different LED product if that would make it an easier project-I must be finished by Monday the 4th. I understand that probably sounds like plenty of time but I also need to figure out how to build the body of the task light and optimally have the wiring/arduino/flex sensor contained within the model so figuring this out ASAP is vital. Thanks so much to your help Runaway. Today I will be finalizing the form of the light, coating a foam body in epoxy resin for a mock up. Eventually I hope to make it out of wood but may not be doing that because of time. Continued advice from anyone is appreciated.

What colour/s ?

Avoid at this time arranging the LEDs in an electrical matrix, that may make things more complicated than necessary. There's a physical bunch of LEDs, but how to connect them [i.e. what to do] depends on some other factors.
What's the power source (a 12V battery pack)?

http://arduinobasics.blogspot.com/2011/05/arduino-uno-flex-sensor-and-leds.html
http://garagelab.com/profiles/blogs/tutorial-flex-sensor-with-arduino

Awesome! Thank you! Color is just bright white. Power source can be whatever is necessary I mean ideally this light would plug into the wall and convert the power itself but for school/project purposes using the USB on the arduino or it's power source converter plug in or batteries would work-whatever isn't going to fry everything if that's what the danger is. I will dissect all this info ASAP Runaway thanks once again. My Dad is more solder/tech experienced than I am and I have to still run out to get the resistors so some delay may come before assembly but this is great. I will also pick up other LEDs, singles and possibly a strand if those are better? Do they sell at strands at radioshack? Which is best and available for pick up/what store without breaking my bank... I guess is what I'm asking.

I guess other questions that could be addressed now would be:

Can I have the arduino/flex resistor in one location that would be about 20" away from the LEDs?
-if changing from the Matrix is also even better because of this I am again open to whatever is best...

Runaway many thanks!

I think I would stay with discrete LEDs (eschew "strands").

It's good you have your Dad to assist, his experience will likely prove a valuable resource.

It'll require some wiring (thin gauge wire is OK for this) for sure.
Others may see it different.

The drawing (attached) shows how I figure easiest - 2 in series with their own resistor, in parallel with all the rest, all going through the one FET, PWM-controlled, I estimate 380 mA.
(The dwg doesn't include the flexsensor, it's just the LEDs circuit.)

I see the sketch (programme) as a loop that's constantly (well, repeatedly anyway) reading the flexsensor and adjusting the PWM output based on that...
And that could be fluid or coarse, depending on your vision of that action.

Good "logic level MOSFETs" are STP40NF10L or IRLZ44, both available from DigiKey.

Maybe you have other resources available. You should buy at least a couple, in case of "mishaps".

I'll stress that you can, and should, come up with the sketch and then implement a modest test of that - while you wait for your MOSFETs to arrive.

tasklt.JPG

You don't have to run a wire from each pair back to the MOSFET.
The pairs and resistors would be assembled in the "head" with two wires running out of it back to the "control box" (one for +12 and the other to the MOSFET's Drain.)

Great. A little of that was over my head but you seem to be following my vision perfectly. I would like a more fluid motion. SO speaking of-we got the flex sensor working with one LED that was just simply on pin 13 but I think because of how the code was that we copied the dimming is too little and it's basically just on/off. Maybe with more LEDs it will be more apparent. Don't understand the MOSFET looking up now and will continue research as I construct the model (excited-right now foam is hardening epoxy finish should be done tomorrow)

Will a proto board for the arduino help? I can just use that to solder on the flex sensor and it's resistor then also use it as an easy out to the LEDs downstream...?? I think I can still pull off the matrix have been doing more and more research on that the only thing that confuses me is that the pins are not just opposite - and + on either side of the matrix.

Is there any reason I can't just do what this sketch shows? http://arduino.cc/en/Tutorial/RowColumnScanning
Picture below:

And then one of the potentiometers is the flex sensor...??

Here is a side view drawing of what my task light will look like and work.
The red lines are describing the motion and the flex sensor.

When the light is compressed it automatically turns off given the flex sensor and when the
user pulls it out-off the wall-the LEDs automatically slowly brighten to full power and full extent
and vice versa for dimming just move the light back closer to the wall.

That's why need about 20" of slack from flex sensor/arduino/wall to the LEDs.

CrossRoads:
Yes, that will be easy to do.
Obtain a 0.1uF and a 1uF cap also for the MAX7219.
Wire up the matrix and the display per the MAX7219 datasheet to start.
http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf
Seg0-7 go to the Anode pins, and Dig0-7 go to the Common Cathode pins.

Crossroads thanks! I also posted in other forum at this link: http://arduino.cc/forum/index.php/topic,150219.0.html
and have been getting help from Runaway Pancake but he has been steering me away from the matrix idea.

I have the flex sensor rigged up working with a single LED still mounted on the arduino uno. Code needs some revision to make it a broader dimming process but I also believe the effect will be more visible with multiple LEDs idk I may be wrong please let me know.

I got the caps and resistors-also picked up an arduino proto board and a separate larger breadboard for testing.
My vocabulary for this stuff is very minimal especially abbreviations so I guess I'm wondering if you could just draw me what you meant.

Clarification-I do not need to be able to control each LED in the matrix I just want all 64 to turn on and dim/brighten as a whole given the flex sensor. This should make it much easier right? especially with the code. I am inferring that I still need the MAX to be able to power all 64 enough correct? What's really throwing me in all the wiring drawings/diagrams the Matrix has pins at the top and left caddycorner to each other and not opposite each other as it is on my matrix. Thanks again for your help and any and all advice is appreciated! Or if even just hopped on the other forum link if easier.

This site is the data sheet for my LED matrix: http://www.adafruit.com/datasheets/BL-M07C881.PDF

This is what I was working off of the just get the flex sensor working with one LED in pin 13" http://arduinobasics.blogspot.com/2011/05/arduino-uno-flex-sensor-and-leds.html

Can I just do something like this: http://arduino.cc/en/Tutorial/RowColumnScanning
-use one of the potentiometers as the flex sensor??

What I don't get from this drawing is necessary MAX or resistors?
/What pins are what on the matrix? How can I tell which side is positive/-?
Actual pins are across from each other but in every diagram they are on left and top...

Thanks AGAIN! Finishing form of light arm tonight and will get deeper here after.

This is where I get confused-cathode/anodes of the matrix.
http://playground.arduino.cc/Main/MAX72XXHardware#Wiring

Wiring a Led matrix

The MAX72XX can drive up to an 8x8 matrix as shown in the schematic below. The labels on the left and the top of the schematic refer to the matching pins of the MAX72XX.

You can build your own matrix out of individual Leds, but there are also pre-wired ones available. They can be directly connected to the MAX72XX. Some are arranged as column cathode and some are column anode (as in the diagram above). Either type will work but you must connect the anodes to the Seg lines and cathodes to the Dig lines and arrange your source data to suit (e.g. be prepared to swap rows for columns).

MY MATRIX http://www.adafruit.com/datasheets/BL-M07C881.PDF
Is the BL-M07C881W-XX which according to the datasheet is: Row-Cathode Column-Anode

HELP thanks to anyone!

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

  • Moderator

In the tutorial you've linked to the two pots are used to position a lit LED (one sets the X-axis position and the other sets the Y-axis position.)

As to which pin is what on a matrix -

  1. if you can find a datasheet then your work is cut out for you
  2. if you can't find a datasheet then you get in there in a DMM and "pin it out", an exercise in process of elimination

Matrixes are for doing letters and pictures with and such, for making a flashlight they're a hassle.
When discussing matters related to your sketch - always post your code.

I don't have a flexsensor, but I have a pot.
I didn't want to rig up a bunch of LEDs (it's your project), but I have a bulb that pulls 120mA (considerable draw), used a MOSFET. So, I rigged that much up and used the following sketch; pretty short and sweet --

/*
   read pot (sensor)
   result PWM
   repeat
*/
const byte sensorPin = 3;
const byte lightPin = 0;
int sensorval;

void setup() 
{
  pinMode (lightPin, OUTPUT);
}

void loop ()
{
  sensorRead();
  analogWrite (lightPin,sensorval);
}

void sensorRead ()
{
  delay(10);
  sensorval = analogRead(sensorPin);
  sensorval = sensorval/4;  //  1024/4 = 256
  if (sensorval < 20)       // for solid OFF "zone"
  {
    sensorval = 0;
  }  
}

I used an ATtiny85 instead of a full-blown Arduino, but, again, same difference.
For the analogWrite pins, use one of the designated PWM pins (D13 is not one.)
For the analogRead, use A0-A5.

> > > I guess I wasn't paying close enough attention - you've bought a matrix already.
I don't have any good suggestions for that (other than not using it.) You'll have to home-run 16 wires or something (not good)? I'm not a 7219 maven. Code intensive little things for being so "handy".
So, I guess your dilemma is: How To Vary the Intensity of LEDs with a 7219?

Also, with a 5x7, say, being a rectangle, basically everyone wants to reckon that as 5 columns and 7 rows.
But a square has as many rows as columns, so whether it's column cathodes or column rows is more, to me, in the eye of the beholder. Page 3 of your linked PDF shows how they figure though. I guess, looking at the labelled side with the pins pointing down, pin 1 is on the left (and pin 16 is directly opposite it on the other side.)

Here's the connections you want.
This code was written for IDE 00223 and is kinda long, but it gets the job done.
Need to declare all the variables with addresses per the MAX7219 datasheet, Table 2.
May have to change "SS" to "SSpin" or similar.

// ***********************************************************************************************
void setup() // stuff that runs once before looping forever
{
  // start up SPI to talk to the MAX7221
  SPI.begin(); // nothing in () because we are the master
  pinMode(SS, OUTPUT);  // Slave Select for SPI  <--- Need this here before any SPI writes

  //  MAX7221 
  // write shutdown register  
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(SHUTDOWN_ADDRESS);  // select the Address,
  SPI.transfer(0x00);      // select the data, 0x00 = Outputs turned off
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  // Serial.println("shutdown register, dislays off");

  //  write intensity register
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(INTENSITY_ADDRESS);  // select the Address,
  SPI.transfer(intensity);      // select the data
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  //Serial.println("intensity register ");

  // write scanlimit register
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(SCANLIMIT_ADDRESS);  // select the Address,
  SPI.transfer(0xFF);      // select the data - FF = all 8 digits
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  //Serial.println("scanlimit register ");

  // write decode register
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(DECODE_MODE);  // select the Address,
  SPI.transfer(0xFF);      // select the data - FF = all 8 digits
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  //Serial.println("decode register ");

  //display test
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(DISPLAYTEST_ADDRESS);  // select the Address,
  SPI.transfer(0x01);      // select the data
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  //Serial.println("digit display test on ");
  delay (100);

  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(DISPLAYTEST_ADDRESS);  // select the Address,
  SPI.transfer(0x00);      // select the data
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  //Serial.println("digit display test off ");
  delay (100);

  // write shutdown register for normal display operations
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(SHUTDOWN_ADDRESS);  // select the Address,
  SPI.transfer(0x01);      // select the data, 0x01 = Normal Ops
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  //Serial.println("shutdown register, displays on ");

  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit0_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip
  
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit1_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip

    digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit2_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip

    digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit3_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip

    digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit4_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip

    digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit5_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip

    digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit6_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip

    digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(digit7_address);  // select the Address,
  SPI.transfer(0xFF);      // all segments on
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip
    
} // end of void setup(), ready to interact with users

void loop(){
  //  write intensity register - vary from 0x00 (dim) to 0x0F (bright)
  digitalWrite(SS,LOW);  // take the SS pin low to select the chip:
  SPI.transfer(INTENSITY_ADDRESS);  // select the Address,
  SPI.transfer(intensity);      // select the data
  digitalWrite(SS,HIGH);   // take the SS pin high to de-select the chip:
  //Serial.println("intensity register ");
}

CrossRoads:
Here's the connections you want.
This code was written for IDE 00223 and is kinda long, but it gets the job done.
Need to declare all the variables with addresses per the MAX7219 datasheet, Table 2.
May have to change "SS" to "SSpin" or similar.

Great thanks a million. Sorry for cross threading but felt could get more answers faster and would have deleted after anyways as I know no one likes a know nothing cluttering good forums, again apologies for my ignorance this is just a project where our teachers really have thrown us in the deep end and expect too much as design students given the time they give us. Alas I have the entire matrix and MAX wired except for 2 things:

  1. What do i do with pin 24 if the matrix is all I want to rig?
  2. As per my calculations-although I don't think I fully understand variables
    I need a 30K resistor to be safe http://www.adafruit.com/datasheets/BL-M07C881.PDF

Instead of the code writing the brightness of the matrix I believe I may try the "bar graph" way of lighting LEDs
to simulate dimming and brightening by just changing the number of LED rows that are lit.

This guy is doing without a MAX??
Does that mean I will get more power to matrix?

Will get resistor tomorrow and try it all out! Excited.