Club Light Controller
           By: Alex Cerruti and Chris Wherry
               EE476 -- Spring 2002

software Design  

Programmed in CodeVisionAVR C, our software interfaces the MCU with the stepper motor, muffin fan, and audio signal to produce a club light that randomly outputs a new color at the detection of a bass beat off an input music signal.  We use the ATMEL 90S8515 at a clock speed of 8 MHz.  By using timer 0, we set the reload value so we would have an interrupt trigger every 1 msec, thus creating our time base for our main tasks in our code.

Test File

Originally, we wrote a simple C file (steptest80.c) to test the operation of our stepper motor to accurately test the movement of the color wheel.  We determined that we needed to pulse the 4 pins of the motor 5 times (or 20 steps) to take the color wheel from one color to the next color.  By pushing push buttons 0, you will make the color wheel turn 20 steps in the counter-clockwise direction, while pushing push button 1, will make the color wheel turn 20 step in the clockwise direction.  Push button 2 would make the wheel turn counter clockwise enough steps to reset the position of the color wheel to position 0 or black. 

Final File

Our final C file (final.c) has one task and multiple functions called from those tasks.  

Task1()

Task 1 would test pin 7 of port D, which signaled whether the temperature was higher or lower than the set point temperature of 90°F.  If the temperature read exceeded 90°F  the muffin fan would turn on and once the temperature would fall below this set point, the muffin fan would turn off.  From the temperature sensor circuit in Figure 3, the fan will turn on when the voltage on pin 7 equals 0V and will turn on when pin 7 equals 5V.   

cw()

This function would turn the stepper motor in the clockwise direction according to how many offset positions the next color is.  The variable color is then updated so it knows what color it just moved to.  

ccw()

This function would turn the stepper motor in the counter-clockwise direction according to how many offset positions the next color is.  The variable color is then updated so it knows what color it just moved to.  

beat()

When beat is called, it grabs the value of the counter to obtain a random number and then takes this number modulo 11 to get a number from 0 to 10. 

Color Codes

0

Black

1

White

2

Light Green

3

Blue

4

Yellow

5

Orange

6

Green

7

Amber

8

Pink

9

Magenta

10

Strobe

First, the program checks to see if color code 10 was selected.  It then goes through a sequence of 5 strobes to generate a strobe light effect.  It first detects whether white (color=1) requires a counter-clockwise or clockwise rotation.  After the color wheel moves to white, a series (5 times to be exact) of counter-clockwise or clockwise rotations are made to produce a strobing effect of the color wheel.  After this strobe is performed, it breaks out of beat() and waits until the next beat is detected.  

If the color code is anything different than 10, by using the new color code versus the current color, we are able to determine which direction the color wheel should be rotated and by how many positions.  More specifically, next color is subtracted from the current color to obtain the number of positions the color wheel needs to rotate.  If this number is negative a clockwise rotation of the color wheel is required to move to the next color.  If this number is positive a counter-clockwise rotation is required.