This weeks assignment was to write a program that would interact with a device I built. So I used one of my boards from the week of input devices, the hello.reflect board. This board has an LED and a phototransistor. Because this board had an embedded program, most of the work this week was writing new code to create the interface and graphics related to the device program.

I wanted to design an interface that would manipulate graphics based upon the data being read from my board. I started by using the Processing Development Environment because it looked familiar and similar to the Arduino IDE which made me feel comfortable using it.

I began by downloading processing from processing.org and then I went through the tutorials to learn how to draw shapes and fill them with colors. After studying some of the examples, I borrowed some parts of the code to write a program for my board. The trouble I had with this was getting the framing numbers filtered out so that the data could be read accurately. The program drew a square and changed the color as the intensity of the light being reflected into the phototransistor would increase or decrease. At this point, I had the program printing the values it was using for the readings which if you can see weren't very precise. I also had to converte and manipulate the data to get more accurate information and readings. This was something I corrected before I moved to the next environment, Python. You can see the colors did change at least, from black to red to yellow.

Next, I decided to use Python. I started with the python file we used for the input boards and changed the coding to filter the framing and display the reading on something like a graph with ovals instead of rectangles. Also, it draws a circle and fills it with a certain color based upon the intensity of the light being reflected into the phototransistor. The colors change from black for low relfection to yellow, then to white for the highest amount of reflection.

Text file of Python Code Text file of Processing Code

Back Home