Interface and Application Programming

This week we were asked to write an application that interfaces with an input or output device that we made. Both Anya and Nathan suggested that I start with Processing, as it is easier to play with for beginners. I have kept my example simple as I don't anticipate doing a lot of interface or application programming for my final project. I managed to get Processing to recognize the signals that my passive infrared motion sensor sent and change the color of the square whenever it detected a motion. I modified one of the example codes in Processing with the help from Rob and Tiffany. Here is the file and here is an image of the codes with some of my annotations:

Processing Codes

A few things I wanted to mention about the code:

As can be seen in the video below, whenever there was motion, the square would turn yellow and the LED on the board would turn on:

Processing Codes with Window 1 Processing Codes with Window 2

This week I also tried to make Neil's RGB board and install Python and Pyserial on my Windows PC.

RGB Board

I didn't have time to make an RGB LED board during the "Output Devices" week. So I made Neil's board this week. Similar to last week, I had to deburr the board a little bit with sand paper after milling it:

Neil's RGB Board Milled Neil's RGB Board Deburred Neil's RGB Board Stuffed
Neil's RGB Board Components

When I tried to program the board I kept on getting the "rc=-1" connection error.

Programming Error

I checked to make sure that none of the components looked overheated, that the RGB board was properly powered and that my programmer board was functioning. After staring at the board for quite some time and not being able to detect any points of poor soldering, I decided to replace the Attiny45 microcontroller (even though the casing looked perfectly fine) as suggested by many people who posted about this error online. And that actually did the trick!

Installing Python and Pyserial on Windows

With some great help from Harry, I was able to install Python and pyserial, and get them to recognize my serial port. Here are the steps that I took:

  1. Download Python 2.7.10 for Windows 64-bit
  2. Download pyserial 2.7 Source Code
  3. Unzip pyserial-2.7.tar.gz, in the folder "pyserial-2.7", find the folder named "serial". Copy/paste this folder into "C:\Python27\Lib\site-packages" folder
  4. Under "Control Panel", search for "environment" to bring up the environment variable settings. Add "C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts\;" to the "Path" variable under "System Variables". I initially followed this tutorial to set up the PATH variable under the "User Variables" section. They should both be okay.

I wanted to thank Rob, Anya, Nathan, Tiffany and Harry for their help this week!