Pages: [1] 2   Go Down
Author Topic: LEDs as sensors, newbie needs help!  (Read 1590 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm currently working on an interface using the bi-directionality of an LED array. They would display a target which the finger has to touch and sense it to locate if the target has been accurately touched...

I have watched Han's video (http://cs.nyu.edu/~jhan/ledtouch/index.html) and have looked at patents for using leds as sensors, but unfortunately I'm quite new to all of this and am a bit lost...

If by any chance you know of a program that does the same thing (array of led translated to screen) or that you have it as 'old work' and that you have moved on to something else, could you please point to me where I could find them?
This kind of thing is very helpful (for anyone who is interested) http://www.provolot.com/projectlog/2007/05/bidirectional_led_sensing_proc.html

I've got very limited knowledge of processing (and arduino coding in general) and a few lines of working code would therefore help me greatly.

with best wishes,

Ymtees
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If by any chance you know of a program

Anyone giving you a piece of code is doing you a disservice. Go figure out what mechanism is at work and how to perform the various functions needed in your mcu.

That's called learning.

Copy-and-paste is for people without a brain.
Logged

0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

once you've done it it's quite easy to understand

here's some quick and dirty code i rushed but i've tried to explain each action, there are better ways but this explains the principal

Code:
// LED with current limit resistor connected to digital pin 2 & 3
// LED - to pin 2 & LED + to pin 3

void setup()
{
  Serial.begin(9600);
  
}

void loop()
{
  long t=0;
// --------- LED Forward Voltage ------------  
  pinMode(2, OUTPUT);    // LED - to pin 2
  pinMode(3, OUTPUT);    // LED + to pin 3
  digitalWrite(2, LOW);  // Make pin 2 0v
  digitalWrite(3, HIGH); // Make pin3 VCC
  delay(10);
// ------------------------------------------

// --- Now Reverse Polarity to charge LED ---
  pinMode(2, OUTPUT);    // LED - to pin 2
  pinMode(3, OUTPUT);    // LED + to pin 3
  digitalWrite(2, HIGH); // Make pin 2 VCC
  digitalWrite(3, LOW);  // Make pin3 0v
// ------------------------------------------  
  
// --------- Now Discharge the LED ----------
  pinMode(2, INPUT);     // make pin 2 input
  pinMode(3, OUTPUT);    // pin 3 still output
  digitalWrite(2, LOW);  // make pin 2 low, it is now input
  digitalWrite(3, LOW);  // Make pin3 0v
  
// now count how many loops until pin 2 becomes logic low and LED is discharged  
  while(digitalRead(2) == HIGH)
    {
      t++;
    }
  Serial.println(t); // report to serial
// ------------------------------------------  
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Anyone giving you a piece of code is doing you a disservice. Go figure out what mechanism is at work and how to perform the various functions needed in your mcu.

That's called learning.

Copy-and-paste is for people without a brain.


I understand I may be sounding as though I want someone to do the work for me, sorry about that, I am keen to learn but am afraid lack of guidance makes it seem as though there is a world I need to understand before I can do the smallest things. A piece of code, which I can decipher, would help me learn as I tweak it, making the whole processing more interactive, focused, and relevant to what I am trying to learn.

Thank you for your reply.

Ymtees
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33408
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you read the page about my experiments with this?
http://www.thebox.myzen.co.uk/Workshop/LED_Sensing.html
Logged

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.instructables.com/id/4x4x4-interactive-LED-cube-with-Arduino/

here is an example of a guy that made a cube with LED sensors, not only did he use LEDs for sensors, he charlieplexed the the cube.
Logged


0
Offline Offline
Sr. Member
****
Karma: 7
Posts: 476
what?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Have you read the page about my experiments with this?
http://www.thebox.myzen.co.uk/Workshop/LED_Sensing.html

Very interesting Mike, i've never taken the time to look that deeply into it, I dont get much time usually, so left it as a cool led hack, although i did see some guy had make two units that could talk to each other at short range
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

P18F4550, Hippynerd, Grumpy_Mike,

Thanks a lot for pointing it out to me, I'm following Grumpy_Mike's example and it works, although results sometimes flicker heavily, with a 10 segment display I bought yesterday (http://www.maplin.co.uk/10-segment-display-2128). Might have been because it was night and there wasn't any 'natural' light.
Grumpy_Mike, thank you for posting both the arduino and the processing code, I'm deciphering it slowly! smiley

I've been told that to achieve my purpose, it would be better (and less complicated) to use a phototransistor in the middle of collated 2x2 or 4x4 arrays for location of a finger quickly touching the screen. If you've got any thoughts, please shoot! smiley

Best,

Ymtees
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33408
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bang!

Yes I think a photo transistor would be much easier to use, there is not all that software faffing about with charging and timing the discharging rate.
Logged

Cairns - Green Island for Winter
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If by any chance you know of a program
Anyone giving you a piece of code is doing you a disservice. Go figure out what mechanism is at work and how to perform the various functions needed in your mcu.
That's called learning.
Copy-and-paste is for people without a brain.
A pretty  ill concieved and ill considered bit of ppoor opinion if ever I have seen one
Everyone learns first by following example and then with experience experimenting to push the envelope a bit further.
In fact thats natures way.

I would ignore such statements
This is a board for posting questions to seek answers not criticism
Unfortunately it is full of these types
Logged

Governments should do what they were designed to do only.
Manage the larger issues best done by Government.
My Family and my Property are no

Cairns - Green Island for Winter
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you follow Mike's LED post and use normal led's there is a program posted here somewhere that gives the code for a function to read the time it takes for an LED to dissipate its charge to zero . If you can't find it by searching  this thread then say so and I will go find it.

Surprisingly the LED used only as a light sensor can be reversed . No resistor is needed. However you are working with wire and capacitance and they vary widely from manufacturer to manufacturer . If you want a longer lead on an LED the only success I have had is with a single core shielded coax type cable with the shield as one of the wires,connected to negative ,  and the core as the other. Two wire shielded cable does not work and neither does twisted pair.. I think they pull in radio wave voltage in the area

The above single wire/shield   works on the coax theory that the signal going into the coax comes out the same at the other end provided the capacitance in the cable does not vary so you should be able to use any length.
« Last Edit: January 25, 2013, 05:39:28 am by tytower » Logged

Governments should do what they were designed to do only.
Manage the larger issues best done by Government.
My Family and my Property are no

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ *dhenry* I understand you wear shoes make of candy so your day does have some 'Sweet Spots' in it...
You seem to "Open Mouth, Insert Foot"... quite often. Really noticeably so.. Too.
Hint... Is this the way that you wish to be treated...?
Did it ever occur to you that the word  "Mechanism" Might not be understood in the context used...
OR that You ARE NOT A Gift From God, sent to save the Arduino Forum, Quite the reverse... IMO

Quote
Anyone giving you a piece of code is doing you a disservice. Go figure out what mechanism is at work and how to perform the various functions needed in your mcu.

That's called learning.

Copy-and-paste is for people without a brain.

From previous code snippets you have posted and your comments about their provenance it would appear that your statement above lacks some credibility ... AS usual...

Bob
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
although results sometimes flicker heavily

Because the code is poorly written.

All you need to do is to understand how this thing works, and code for it. The code posted earlier can serve as a good starting point: you will need to specify charge / discharge / measurement pins - for 6 leds, you need at most 7 pins.

The trick, with this approach, is to use time-out, so the measurement time isn't too long when it is dark.

A better approach is to use the adc module (aka charge transfer): it is much faster, offers higher resolution and is considerably simpler.
Logged

Cairns - Green Island for Winter
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Charge transfer -adc module
I suspect I have seen a post on this somewhere here but I have searched here for  "charge transfer " and "LED charge transfer " and "adc module " and the only thing that comes up is the above post.

I have done the same searches on DuckDuckGo and not seen anything I could directly associate with an LED or even a capacitor apart from Franklin flying a kite?

Would you please elaborate on this  hopefully with a reference point so I can see what you are talking about.
Logged

Governments should do what they were designed to do only.
Manage the larger issues best done by Government.
My Family and my Property are no

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
A pretty  ill concieved and ill considered bit of ppoor opinion if ever I have seen one
Everyone learns first by following example and then with experience experimenting to push the envelope a bit further.
Despite my normally impeccable judgement, strangely, I find myself agreeing with tyTower.
Logged

Per Arduino ad Astra

Pages: [1] 2   Go Up
Jump to: