making a crude camera with an ldr ?

hi guys

i was just wondering if its possible to make some sort of a crude camera using and ldr

like the following :

  1. get the analog read from the ldr .

  2. map it from 0 to 255 .

  3. using processing to asign a value for each pixels from the analog read .

when something passes along the ldr blocking some light it should produce some sort of a radar image .

the the part that i am sturgling with is the processing code
i wrote this but didn't work just keep blinking :

import processing.serial.*;

Serial port ;
int data ;

void setup() {
  size(400,400);
  port = new Serial(this , Serial.list()[1] , 9600 );

  
}
  
  void draw() {
    
    if (port.available() > 0) {
      data = port.read();
    }
    
    loadPixels();
    for( int x=0 ; x <width; x++) {
     for ( int y = 0 ; y < height ; y++){
    pixels[x+y*data] = color(data);
     
  }
    } 
    updatePixels();
}

How will your program know where the LDR is pointing, to make the radar scan?

Hi,
Can you post a picture of your project so we can see your component layout.

As @jremington has pointed out you need to have not just brightness data, but position data.

Even John Logie Baird had to use a lens and scanner to detect and transmit brightness and position of the spot, when reproducing an image.

Tom.. :slight_smile:

Plus the fact that an LDR is not fast enough to have a decent scan rate even assuming you had a Nipkow's disk.

isn't just possible to assign a value for each pixel depending on the brightness values , i mean it doesn't have to be perfect i just want an image indication that something had passed in front of the LDR .

what if i want to give it the position values is there any thing other than a servo which i don't have at the moment ? a steady moving mechanism on a ball bearing maybe ?

what the processing code for that ? ( constructing an image using analog value as well as the position value )

ahmed44:
isn't just possible to assign a value for each pixel depending on the brightness values , i mean it doesn't have to be perfect i just want an image indication that something had passed in front of the LDR .

what if i want to give it the position values is there any thing other than a servo which i don't have at the moment ? a steady moving mechanism on a ball bearing maybe ?

what the processing code for that ? ( constructing an image using analog value as well as the position value )

What pixels? Where do they come from? Why do think there are pixels involved?

Paul

One LDR = one pixel. You don't get an image if you only have one pixel.

...R

Strange concept!

i was just wondering if its possible to make some sort of a crude camera using and ld

Given reply #4 then no.

Paul_KD7HB:
What pixels? Where do they come from? Why do think there are pixels involved?

Paul

the pixels in the processing sketch !!

Robin2:
One LDR = one pixel. You don't get an image if you only have one pixel.

...R

i know that i will need a photodiode array to do such a project but the ldr itself = one pixel at a time and by using a multiple reading values i could get n pixels i mean its not necessary that the ldr it self is moving with a steady position determining mechanism if the object it self moves in front of it as the reading values will change in some pixels of the processing sketch producing an indication of a passing object .

what my question really is how to assign a value for each pixel in a processing sketch ?

and if its not possible can any one give me a part number for a photodiode array i would really appreciate any help

A photo diode array and an LDR are two completely different things. Which do you really plan to use?

There is nothing to stop you collecting a series of numbers (they could come from any type of sensor) and sending them to a PC one after the other, perhaps accompanied by an index number - something like

<1, 45>
<2, 123>
<3, 0>
<4, 0>
<5, 87>
etc

Or you could collect the values into an array on the Arduino and send them all at once like this
<45,123,0,0,87>

Either way you can then do what you want with the data on your PC program.

...R

Thanks for that, I now get what you are thinking.

What you will get is not so much an image but a graph of light readings.

what my question really is how to assign a value for each pixel in a processing sketch ?

You take readings at regular intervals and assign them to successive pixels in the processing sketch until you reach the maximum you are storing. Then you start again and fill that single row of pixels from the beginning, just like before.

The results arn't going to look very good as you just have a single row of pixels in your image and close shades of grey are hard to distinguish. You would be better plotting this as a graph, you would get more information.

In a way, this is exactly how an oscilloscope works and if you just do that you will get the same sort of problem of the appearance of just a random sequence of flashing signals. The oscilloscope solves this problem by the use of a trigger. That is the voltage must cross some point before starting the sweep. Likewise your one dimensional picture can have a trigger, that is you don't start filling in successive pixels until the reading of the LDR reaches a specific point. You then fill them in at a fixed rate and when you get to the end you stop and wait for an other trigger.

A one dimensional photo diode array tends to be very expensive, but if you have a scrap document scanner you can salvage one from that.
Two dimensional arrays of small size are almost unknown, but there is one built into a Nintendo Wii Remote. I make absolutely no promises about this link because it is on instructables and that is normally a sign of a crap project, but you might want to look at this:- Wii-Remote IR Camera Hack

If you only want a graph of the LDR readings over time, you can use the Arduino IDE's Serial Plotter feature instead of Processing. It's at Tools > Serial Plotter.