Go Down

Topic: LEDs as sensors, newbie needs help! (Read 1 time) previous topic - next topic

ymtees

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

dhenry

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.

P18F4550

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: [Select]
// 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
// ------------------------------------------  
}

ymtees



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

Grumpy_Mike


Go Up