The goal of this project was to build an interface from two simple switches to a Windows laptop so that the laptop could play one of two bird songs, depending on which switch was closed. The idea is to have a bird peck at the switches to control what song is played.
There are two parts to this project:
The microcontroller was built on a generic
board designed for ECE476.
This board includes the microcontroller clock and RS232 serial interface. Two
bits of PortC were attached to switches (or interruptor boards). The main board and two slotted interrupter units are shown below. Three wires (5 volts, ground, and output) connect each sensor board to the main board.
The microcontroller code is written in CodeVision C and consists of two parts. The timer 0 interrupt service routine (ISR) runs a state machine to debounce the switches and blinks an LED to show the system is alive. The main loop sets up the I/O ports and timers, then continuously polls to see if the PC has sent the character "s". When the PC sends the "s", the microcontroller responds with a serial string consisting of two numbers.
The Matlab PC code.
To run this program, you must own Matlab 7.0 or above. The program opens a serial port, then queries the user for two wav file names, which will be the songs played when the switches are pressed. It then opens a window which contains a quit button, the two filenames and two numbers indicating the total number of times each button was pressed. The program then repeats a query to the microcontroller (by sending a "s") and listens for the string of two numbers returning from the microcontroller. If either number is nonzero, the program plays the appropriate song.