Hardware-based Pulse Width Modulation (PWM))

In this lab, you will begin by continuously adjusting the brightness levels of 12 Light Emitting Diodes (LEDs) six of which will be connected to hardware PWM outputs on the AVR, and the other six to pins that are not supported by hardware PWM.

In this first part of the lab, you will use a single microcontroller (one ATMEGA48 or ATMEGA88) to output a prescribed pattern of brightness levels to 12 LEDs.

Light Organ from pre-recorded data

Program the brightness pattern, using the lowest 12 LEDs in songArray from lab 5. This will give you the following:
// Light-organ song; elements of array are on logarithmic scale 1-7
//fade out
	songArray[ 0][ 4] = 6;  // First pad
	songArray[ 1][ 1] = 6;  // Second pad (harmony)
	songArray[ 1][ 4] = 7;  // Second pad (melody note)
	
//fade out
	songArray[ 2][ 8] = 7;
	songArray[ 3][ 4] = 6;
	songArray[ 3][ 6] = 6;
	songArray[ 3][ 8] = 7;

//little
	songArray[ 4][ 9] = 7;
	songArray[ 4][ 7] = 5;
	songArray[ 5][11] = 3;  // high wail
	songArray[ 5][ 9] = 7;
	songArray[ 5][ 7] = 6;
	songArray[ 5][ 4] = 6;
	songArray[ 5][ 2] = 5;

//star (variation of note for a rest or longer duration note)
	songArray[ 6][ 8] = 7;
	songArray[ 6][ 6] = 4;
	songArray[ 6][ 4] = 6;
	songArray[ 6][ 1] = 5;
	songArray[ 7][ 8] = 7;
	songArray[ 7][ 6] = 4;
	songArray[ 7][ 4] = 6;
	songArray[ 7][ 1] = 5;

//now i
	songArray[ 8][ 7] = 7;
	songArray[ 8][ 4] = 5;
	songArray[ 8][ 0] = 5;
	songArray[ 9][ 9] = 4;
	songArray[ 9][ 7] = 7;
	songArray[ 9][ 4] = 6;
	songArray[ 9][ 2] = 4;
	songArray[ 9][ 0] = 7;

//wonder
	songArray[10][ 6] = 6;
	songArray[11][ 8] = 4;
	songArray[11][ 6] = 7;
	songArray[11][ 4] = 6;
	songArray[11][ 1] = 4;

//if you
	songArray[13][ 8] = 4;
	songArray[13][ 1] = 6;

//are (variation of note for a rest or longer duration note)
	songArray[14][ 4] = 7;
	songArray[14][ 1] = 6;
	songArray[15][ 4] = 7;
	songArray[15][ 1] = 7;
Arrange your LEDs in one row from left to right.

Program your AVR so that this song "plays" on the 12 LEDs defined by songArray[*][0] for the leftmost LED, songArray[*][1] for the next LED, and so on, all the way up to songArray[*][11] for the rightmost LED.

The song will play at a steady tempo, and you should be able to adjust this tempo in your program and demonstrate the light organ for various tempo rates.
3/10

Make up some of your own intersting brigthness patterns, chaser patterns, etc., that demonstrate the functional difference between the pins that have hardware support and those that don't, and explain your approach to illustrating the difference between presence or lack of hardware PWM support.
2/10

Light Organ from live data

Modify the andantephone of Lab 5, or the musikeyer of Lab 4 (your choice), or any other configuration with 12 analog inputs to function on your 12-LED light organ. Alternatively, if you wish, instead of using all 12 inputs and outputs, devise a simpler means to demonstrate the difference between hardware pwm support and lack thereof, for some realtime "live" process.
3/10

Answer questions on this lab:
2/10

Bonus questions

Bonus points (optional): Modify your andantephone from Lab 5 to use the six PWM outputs of the last chip ("LASTER") to drive six analog loads (e.g. six LEDs), instead of the original serial output from the andantephone. Program the new andantephone with the following song:
LED NUMBER
-
6                         7  7           4
5                   7  7        7  7           4     6  4  6
4                            7        7  7
3                6     6        7  4        7  7        4
2                                                 7  7
1             7  7     7     6     7     6     7        7  7
------------------------------------------------------------
PAD NUMBER:   1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
------------------------------------------------------------
Numbers in the inner part of the table indicate the same
logarithmic units as Lab 5, but now you can go from 0.255, i.e.:
blank space denotes 0
1 denotes 1
2 denotes 3
3 denotes 7
4 denotes 15
5 denotes 31
6 denotes 63
7 denotes 127
8 denotes 255 (full brightness of the LED)

More advanced (ambitious) bonus question (optional): create a serial communications ring topology using 2 or more AVRs, so that the output of each AVR in the ring goes into the input of the next AVR in the ring. Use this system architecture to implement an andantephone having 6N pads and 12 notes, where N is the number of AVRs that you use. Suggested configuration: 18 pads and 12 notes, with 3 AVRs, using 12 PWM outputs from any two of the AVRs.