As I've decided to make a camera which can at least classify apple and non-apples, I decided to keep the part that "learns" in the software side. I calibrated my two-layer Neural Net in MATLAB with the interface functions provided by Andrew Ng from Stanford. I used 'fmincg' as the optimization algorithm. To get the range of analog values was important in this case. If I can get the values, I could took many images from either apples (labeled positive) or other stuff(labeled negative) that can be used to train my neural nets. In case, to provide a base set of images to train my neural network, I write a small random image generator script which can create patterns similar to the patterns that can be generated by the board.

Meanwhile, I was trying to improve my board and through talking with Palash at the last clinic on Sunday, we have figured out that we didn't need the shift register at all. 328p provided enough pins for analog inputs and digital outputs. In this scenario, I would yield each digital pin low one by one iterating through eight rows. If I can do this with a delay of minimum 100 ms, than I can take reliable analog values. One caveat would be that I had to cut copper on top in order to provide current for higher rows; that could be source of noise, but I had to try it first.

I cut my board, even the endmill was new, board was clean and I pressed the endmill on board a little, some parts were not cut. I used a razor as a solution but I had doubts.

Then I went on to produce the pinhole box. There is a simple program called LUBAN developed by Larry Sass from Design and Computation group at MIT that allows you to transform any reliable mesh model into press-fit surfaces.

And it also organizes the pieces onto a surface within a rhino file, then you just cut them.

I used a masonite board and painted them matte black and

Assembled them. put temporary piece for FTDI connection which will be replaced by after settling on an appropriate location for the board.

I sandwiched a thin layer of metal between two black cardboards for the pinhole cavity and paper sanded the metal in order to reduce the amount of reflection hence noise. I made a small hole in thin metal by a pin.

Then, I cut a new board, which was cut perfectly.

But, I was unable to program it. Checked for shorts, asked Amanda and Nadya, we were unable to point to the error. Now, it seems to me that even I tweaked the pad sizes and line weights, with 600 dpi, there is no guarantee that the lines are perfectly separated from each other, we may have missed a short.

I cut it again. Now, I was able to program by 328p. I get through the Neil's "hello_light.45.c" code and tried to reinstate my memories with bit math. In the end, decided to program with Arduino as I was stressed out considering the remaining time. I tried to program my chip with this Arduino code:

const int aIn1 = A5;
const int aIn2 = A4;

const int dO1 = 10; 
const int dO2 = 9;

int inputs[]={aIn1,aIn2};
int outputs[]={dO1,dO2};

int lightVals[2][2];

void setup() {


  pinMode(aIn1, INPUT);
  pinMode(aIn2, INPUT);

  pinMode(dO1, INPUT);
  pinMode(dO2, INPUT);

void loop() {
  for(int i = 0; i < 2; i++){

    digitalWrite(outputs[i], LOW);

    for (int j = 0; j < 2; j++){

      lightVals[i][j] = analogRead(inputs[j]);

    digitalWrite(outputs[i], HIGH);

  for(int i=0; i < 2; i++){
    for(int j=0; j < 2; j++){

After long sessions of debugging, tweaking, simplifying/complexifying the code, I was unable to get any ADC values from my board. I went on pasting my vinyl and copper. I then soldered the first row, connected some pieces with wires from the back and attach holders to be able to move the positions of the board to settle on the light field.

I guess I was little unlucky through the end. I would like to continue on this project, I feel really close to produce my first image with my camera:). I will try replacing the chip, and then ask some experts. Will work on this during the IAP. Thank you for reading.