Assignment

This week assignment was design a board having a sensor and measure something. There were some examples already in Neil's keynotes that were good for a start. I tired the temperature sensor, switch and the microphone. Finally I designed a board for a phototransistor and measured the changes in the ambient light with that.

For the phototransistor sensor I first designed the board in eagle, then made the board using the milling machine and soldered the components.

Here is my board PNG file. Board traces and Board interior.

Then I downloaded the files hello.light.45.c, hello.light.45.make and hello.light.45.py from Neil's keynotes. Connecting the board via an FTDI cable to the computer and attaching it to the fabISP, I programed the board by using the command "sudo make -f hello.light.45.make program-usbtiny"in the terminal. Note to be in the directory that the file exists before executing these commands.


Here is my eagle file and pcb board. download

For running the .py file, the serial port to which the board is connected should be known. Using mac I used the command ls /dev/tty.usb* to find out which serial port my board is attached to. For me it was /dev/tty.usbserial-FTFA7VQO. Then using the command "python hello.light.45.py /dev/tty.usbserial-FTFA7VQO" I ran the .py file.

here is the py file: download


Phototransistor sensing the normal light in the room.

Phototransistor sensing the light while it is covered with my finger.

Code modifications

To achieve my function, i need to modify the light.c code.The following parts of the code were added to code:
• led pin definitions;
• set threshold on the phototransistor for the led light to come on;

For my own record, I have extracted and included below, aspects of the code that was added or modified:

Here is the code file: download
It was noted that the phototranistor was very sensitive to any changes to the ambient light in the room. This would make it harder to establish a reliable light-to-darkness change range with my final project device. When I repeated the test at home, the phototransistor was even more sensitive, as there was a flood of light from a near window. I experimented with pushing blutack around the PT to block ambient light. Once the body of the PT was encased in this opaque material the results were much more stable (without any oscillations) and repeatable: