interactive leds panel with arduino

hi guys ,

i gave up with PIC18F4520 and mplab, i have bought an arduino atmega 168 board , and i have done the circuit connecting it with a tlc 5049and 16 leds , i have found some libraries in arduino software it's very helpful than the mplab , now my circuit works and my leds blink ,but i have to connect the whole thing with 2 photo IR diodes, the first emmits and the second receives so as to get an interactive panel with leds blinking just by moving my hand upon the circuit , so my problem remains in how can i connect these IR photodiodes on the test board , ihave followed some instruction on some websites on how to connect them but , im not getting any results , please , my internship period of time is running out unfortunately , i have to get it done this week . thanks for any suggestions . thanks guys

i ve been based on many ancient projects similar to mine coz im using exactly the same components but unfortunatly it doesnt contain IRleds for interactivity , you can understand more , by seeing these links thanks "photodiodes"

Can you explain a little more about what it is you're trying to do?

You've got an IR emitter and an IR photodiode, right?

How are these positioned? Are you breaking the beam between the two or triggering on reflected light (off a hand)?

(BTW, please don't cross-post - it makes people...cross)

[EDIT] Sometimes it can be difficult to distinguish IR devices - Tx and Rx may have similar packages. A good way to find if your Tx is working is to look at it with your camera phone, or digital camera's LCD viewfinder.

you will understand more with this vid , but this one is an analogic panel (without) microcontroller , me i have to do it with microcontroller that's why ive chosen arduino instead of pic , btw i have a confusion abt using phototransistor or photodiode , they play the same role but i dont knw whiwh one i can use to be with the diode that receives plus i dont knw how to get them on the board , ive tried different schemes but it didnt work thanks

Well, first thing I’d say is make sure your photodiode has some good optical filtering on it so it only receives IR, otherwise you’re going to have all kinds of problems with feedback!

Have you got a spec for the Tx/Rx pair?
Another potential problem might be if the devices have too wide an angle of acceptance, in which case, you’d have to put physical baffles to stop direct illumination.

How have you got the photodiode wired to your Arduino?

thanks its very kind of you , but i think you should get another glimpse on my prevoius messages if u dont mind i think u ave missed somethings abt what i said , that's the question !!! i dont knw how to make it opn the board , if u see all the schemes that i gave you u ll see where i am in this whole thing , i dont knw if i shoud ude photodiode or phototransistor with the receptive diode , i dont knw how to connect them , i have made some attempts in vain, u could get a lot of infos if u want from the docs that i gave u thanks

confusion abt using phototransistor or photodiode

A photo diode and a photo transistor are virtually the same thing. Both detect IR light.

When you say photo diode do you actually mean IR LED, although it is a diode is is not the same thing. An IR LED actually generates light.

On the link you posted then if you take the circuit called "An IR phototransistor" and connect the signal output to an Arduino analogue input pin you will be able to read the amount of IR light it is receiving. You have to have a IR LED emitter close to it so the light will bounce your hand back into the sensor. This IR LED can be connected directly to the supply and not need wiring to the Arduino.

I had a look at the IR tutorial - it looks pretty comprehensive.

I’d guess you want the the arrangement in section 2.1, but:
a) I don’t know how much test gear you’ve got (camera phone/digital camera/camcorder, multimeter, oscilloscope…)
b) I don’t know how much experience you have with electronics.

Forget about the blinking lights, just cut down your test setup and software to the bare essentials of the IR diodes, resistors and Arduino. Use the Arduino as your test gear.
Use the serial monitor to read back values from the analogue pins.
Get hold of a working IR remote control to show that your receiver is working.
Get creative.

ok man , i have solved the problem i ve bought a phototransistor and it works not badly , but the leds dont light very well , so i had to reverse the the two sides "cathode anode" and with that , i ve got a better result but not that good , there is not a precision in lighting when my hand goes upon the panel it still weak and not surrounding a higher area superior than 3cm upon the leds , and could give me the reason why the photodiode didnt work and with the phototransistor it did works; and why doing such thing by reversing the cathode and anode would affect on the whole function , so i cant understand why , thanks for responding the 2 questions thanks guys

and why doing such thing by reversing the cathode and anode would affect on the whole function

You have something seriously wrong with your hardware or at least with what you think. There is no way an LED will work at all if it is the wrong way round. There will be no light out of it at all, it's pure physics. So if you did get something out of an LED wired up n both directions you are not doing what you think you are doing. Post a schematic or a photograph.

You need to post the code (using the hash icon in the reply box) that you are using before we can give you advice on that, but it sounds like this is wrong as well.

Basic Pin setup:
------------ —u----
ARDUINO 13|-> SCLK (pin 25) OUT1 |1 28| OUT channel 0
12| OUT2 |2 27|-> GND (VPRG)
11|-> SIN (pin 26) OUT3 |3 26|-> SIN (pin 11)
10|-> BLANK (pin 23) OUT4 |4 25|-> SCLK (pin 13)
9|-> XLAT (pin 24) . |5 24|-> XLAT (pin 9)
8| . |6 23|-> BLANK (pin 10)
7| . |7 22|-> GND
6| . |8 21|-> VCC (+5V)
5| . |9 20|-> 2K Resistor → GND
4| . |10 19|-> +5V (DCPRG)
3|-> GSCLK (pin 18) . |11 18|-> GSCLK (pin 3)
2| . |12 17|-> SOUT
1| . |13 16|-> XERR
0| OUT14|14 15| OUT channel 15

  • Put the longer leg (anode) of the LEDs in the +5V and the shorter leg
    (cathode) in OUT(0-15).
  • +5V from Arduino → TLC pin 21 and 19 (VCC and DCPRG)
  • GND from Arduino → TLC pin 22 and 27 (GND and VPRG)
  • digital 3 → TLC pin 18 (GSCLK)
  • digital 9 → TLC pin 24 (XLAT)
  • digital 10 → TLC pin 23 (BLANK)
  • digital 11 → TLC pin 26 (SIN)
  • digital 13 → TLC pin 25 (SCLK)
  • The 2K resistor between TLC pin 20 and GND will let ~20mA through each
    LED. To be precise, it’s I = 39.06 / R (in ohms). This doesn’t depend
    on the LED driving voltage.
  • (Optional): put a pull-up resistor (~10k) between +5V and BLANK so that
    all the LEDs will turn off when the Arduino is reset.

If you are daisy-chaining more than one TLC, connect the SOUT of the first
TLC to the SIN of the next. All the other pins should just be connected
BLANK on Arduino → BLANK of TLC1 → BLANK of TLC2 → …
XLAT on Arduino → XLAT of TLC1 → XLAT of TLC2 → …
The one exception is that each TLC needs it’s own resistor between pin 20
and GND.

This library uses the PWM output ability of digital pins 3, 9, 10, and 11.
Do not use analogWrite(…) on these pins.

This sketch does the Knight Rider strobe across a line of LEDs.

Alex Leone <acleone ~AT~>, 2009-02-03 */

#include “Tlc5940.h”

void setup()
/* Call Tlc.init() to setup the tlc.
You can optionally pass an initial PWM value (0 - 4095) for all channels.*/

/* This loop will create a Knight Rider-like effect if you have LEDs plugged
into all the TLC outputs. NUM_TLCS is defined in “tlc_config.h” in the
library folder. After editing tlc_config.h for your setup, delete the
Tlc5940.o file to save the changes. */

void loop()
int direction = 1;
for (int channel = 0; channel < NUM_TLCS * 16; channel += direction)

/* Tlc.clear() sets all the grayscale values to zero, but does not send
them to the TLCs. To actually send the data, call Tlc.update() */

/* Tlc.set(channel (0-15), value (0-4095)) sets the grayscale value for
one channel (15 is OUT15 on the first TLC, if multiple TLCs are daisy-
chained, then channel = 16 would be OUT0 of the second TLC, etc.).

value goes from off (0) to always on (4095).

Like Tlc.clear(), this function only sets up the data, Tlc.update()
will send the data. /
int val = analogRead(2);
int ledval = (val-(2048+1024))4;

if (channel == 0)
direction = 1;
Tlc.set(channel - 1, 1000);
Tlc.set(channel, 4095);
if (channel != NUM_TLCS * 16 - 1)
Tlc.set(channel + 1, 1000);
direction = -1;

/* Tlc.update() sends the data to the TLCs. This is when the LEDs will
actually change. */



i read that the intensity could be tuned by controlling the PWM , i found some help on some sites, in which there is a bunch of explanation that would help you helping me lol , and the important thing is that i have to introduce the tlc in that controlling of intensity coz the arduino controls the leds via the tlc 5940 . the next docs will show you some examples on the tlc intensity control. tlc intensity control

int val = analogRead(2);
      int ledval = (val-(2048+1024))*4;      

So, "val" is 0..1023, so "ledval" is -12288..-8196.

That doesn't seem right to me.

forget the program now, and let us move to the similarity of wavelength between the two leds "sensor,emitter" coz i think its due to that difference as grumpy posted in "phototransistor sensitivity" dialogue, i thank him btw, so i think its due to that , tha im not having precision and high detection of the move , i modified the valstart code on my prog and with tha i could get a better lighting from the leds , i just need more precision in the detection coz the leds lit randomly when im not posing my hand upon it instead of being turn off but it works well when im doing the move by my hand + its not enough high coz i need a height of 50cm to get the objective, thanks guys

What did you not:-

post the code (using the hash icon in the reply box)

It makes it much easer to see.

OK, so what you have to do is build things up slowly. First of all send fixed values to the TLC chip so you can see if it is responding to the commands you send it.

Then forget about the lights and concentrate on the values being returned from the light sensors. Get them printed out and try and get the dynamic range up. I am still not sure what exact setup you have on the sensor side especially with regard to what you are using to illuminate the sensor.

IR LEDs and sensors can have sensitivity peaks at different wavelengths and you get maximum sensitivity if you match them but there still should be some response.

Phototransistors are made to drive op-amps or transistors to amplify the voltage range from the variation in light.

with no op amp the voltage difference between max dark and max light could be say, 0V to 5V...

if you connect the phototransistor to a non-inverting op-amp or comparator, you can amplify the difference range to say 0V-10V instead of oV to 5V.

this will make the LEd's in your case more sensitive and responsive if paired with the right range values of the arduino analog pins.

be careful with sensitive GAINs in analog amps. and good luck with your project!

if you connect the phototransistor to a non-inverting op-amp or comparator, you can amplify the difference range to say 0V-10V instead of oV to 5V.

this will make the LEd's in your case more sensitive and responsive if paired with the right range values of the arduino analog pins.

He's (sorry, sexist assumption there - feel free to contradict) trying to to connect his (her) IR detector to an arduino - what would be the point of amplifying the signal to 0-10V?