Vous êtes sur la page 1sur 2

20 pixel camera

The 20 pixel camera consists of 20 LEDs acting as photo sensing devices. Each LED forms 1 pixel. The aim of this project is demonstrate the basic principle of operation for an actual camera which consists of millions and millions of photo sensing elements which are less than few hundred nanometres small. We will be using AVR based Arduino board for working around the cameras basic operation.

We will be operating each LED in common cathode mode. The common cathode will be connected to +5V. The other end of the LED will be connected to 1k Ohm resistor and which will be connected to the I/O pin of the arduino board. The idea is to reverse bias the diodes by switching the IO pins to output low. Then the LEDs will not conduct and behave like capacitors. Once charged we will switch the IO pins to high Z and wait what happens. If there is light there will be a very small photo current. This current will discharge the LEDcapacitors. The more light the more current the faster. After discharging the capacitor long enough we can detect that the pin floated from low to high. Measuring the time to reach this transition indicates how much light reached the LED. It sweeps over the pins and sets them to output 0V. Then it initializes the arrays to hold the reference milliseconds. After this the pins are set to input. Since they are already set to low this implies that the pullups will not be activated. We have now high Z input pins. Notice that some pins are excluded. These pins are connected to the serial chip and the Arduinos LED. They will not deliver any reasonable readings unless you have a board where these additional loads can be disconnected from the controller. In this case you may want to change the pin_is_ok function to return always true. All others must satisfy with a 17 pixel camera. Before you start to disconnect the serial connection dont forget to think about how you want to transfer the data to your computer.

The main loop will now iterate the same thing over and over again. For each LED it will look if it has transitioned to high. If so it will pull it low by setting the pin to output. Then it computed the time since the last transition. Then it will put the pin into high Z mode again by setting it to input. Here I explicitly rely on the fact that pinMode commands are somewhat slow. Thus the LEDs will have quite some cycles for charging. Once all LEDs are processed the results are pushed through the serial line. This must happen in a separate step in order to avoid jitter in the measurement timing. You may wonder about the transform function.

Vous aimerez peut-être aussi