Changes

Students/MikeTeall

5,646 bytes added, 00:17, 19 March 2010
Final Project
== '''Final Project''' ==
<br>
[[Image:joystickBoard1.jpg]][[Image:Board2.jpg]][[Image:LED1.jpg]][[Image:LED2.jpg]][[Image:Mounted.jpg]][[Image:Mounted2.jpg]][[Image:led_matrixWtf.pngjpg]]<br>Demonstration Video: http://www.youtube.com/watch?v=FLu9jkhtI2Q Materials:  Project Box 3"x5", Freeduino, Old Analog flight joystick 15 pin, 15 pin solderable female connector, Toggle Switch, 9v Battery, 35 red LED's (only 25 used for project), a 2" 8 ohm speaker, An unprinted circuit board, screws, a whole lot of wire, and the rest of my solder.  After revisions to my project due to feedback from my Instructor and Ta, I have decided to make an instrument spanning two octaves starting on c4 and ending on b5. The sound circuit will be very simple, going from digital output pin 2 of the arduino through a 100 ohm resistor, and one capacitor into the positive terminal of the speaker, and the other speaker terminal going to ground. I am going to make a 5x7 led matrix that will utilize a 5x5 portion for the project. The arduino LED's and the matrix sound circuit will be a very challenging memory game, like Simon, only there will be 25 choices instead of 4mounted on an unprinted circuit board. I will try This circuit board has 19 one inch or so pieces of stiff wire soldered into it to incorporate sound act as pins, so the whole circuit board simply plugs directly into the setuptop of the freeduino. Each LED will have it's own frequency associated with it to help the user associate tone with positionThere are 5 analog inputs, 11 digital outputs, 1 +5v, 2 Gnd. The game will be controlled by control of the device is an old analog joystick with x and y axis, 2 buttons, and an adjustment wheel that I am using as a third button. There will be three different modes of interaction: In Free play mode the button user only has to move the joystick around on the stickx and y axis to produce the respective tones. I am trying In selective mode the user will move the stick to work on routines that any position, but the sound will randomize only be produced when the user presses the patternstrigger button. For demo mode, and increase the number user simply pushes the top button and speed to make the game fully stand alonea preprogramed melody will play. The materials include 35 red leds Melody Demo: Uppercase letters are sharp, lowercase are normal notes. |-C---C-----|-d-C-d-C-----|-d-C-d------|----------------| |---b----F--|----------b--|--------F---|-b-a board -b-a-G-b-a--|   Actual Used Code: /* Vis 147a Final Project "Analog Joystick as an instrument" Written by Mike Teall*/ //initializing both indexes int oldindex = 0; int oldindex2 = 0; //my array of frequencies from c to mount them intob over two octaves, with one dead zone in the middle int myTones[] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, 0, 523, 554, 587, 622, 659, 699, 740, 784, 830, 880, 932, wire988}; //this array is holding the pin numbers driving the row of my led matrix int myRowPins[] = {3, over one hundred sixty solder points4, small 8 ohm speaker5, an enclosed project box with a red lense6, 7}; //this array is holding the pin numbers driving the arduinoColumn of my led matrix int myColPins[] = {9, 10, 11, 12, 13}; //this array is holding the joystickindices to notes stored in myTones for the pre-programmed //tune int myTune[] = {14, 11, 14, 6, 15, 14, 15, 14, 11, 15, 14, 15, 6, 11, 9, 11, 9, 8, 11, 9}; //these are note durations and used to control loop speed during pre-programmed tune int durations[] = {100, 100, 200, 400, 100, 100, 100, 200, 400, 100, 100, 200, 400, 100, 100, 100, 100, 100, 100, 400}; //Initialization Routinevoid setup() { // initialize serial communications (for debugging only): Serial.begin(9600); // definining these digital pins as outputs pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); //Initializing Row Pins to High digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, HIGH); } //Main Program Loopvoid loop() { // read the sensors: int val = analogRead(0); int val2 = analogRead(1); int val3 = analogRead(2); int val4 = analogRead(3); int val5 = analogRead(4); //map sensor inputs to useful ranges int selector = map(val3, 1, 850, 0, 1); int button1 = map(val4, 1, 850, 0, 1); int button2 = map(val5, 1, 850, 0, 1); int index = map(val, 1, 850, 0, 4); int index2 = map(val2, 1, 850, 0, 4); int index3 = index2*5; //continuous play mode if (selector == 0) { if ((index != oldindex) || (index2 != oldindex2)) { //turn off old led, turn on new led digitalWrite(myColPins[oldindex], LOW); digitalWrite(myRowPins[oldindex2], HIGH); digitalWrite(myColPins[index], HIGH); digitalWrite(myRowPins[index2], LOW); } //choose a 15 pin female connectortone from the myTones array int thisPitch = myTones[index+index3]; //Serial. I hope it works out and println(button2); // play the pitch: tone(2, thisPitch, 10); //keep track of old index values so we have some fun with itcan turn off the old led in case of change oldindex = index; oldindex2 = index2; } //this is trigger mode, where no sound will play unless trigger is pulled if (selector == 1) { if ((index != oldindex) || (index2 != oldindex2)) { digitalWrite(myColPins[oldindex], LOW); digitalWrite(myRowPins[oldindex2], HIGH); digitalWrite(myColPins[index], HIGH); digitalWrite(myRowPins[index2], LOW); } //selects tone in case trigger is pulled int thisPitch = myTones[index+index3]; //check trigger if (button1 == 0) { //trigger pulled, play tone tone(2, thisPitch, 10); } oldindex = index; oldindex2 = index2;  } //This is the pre-programmed routine of "Final Countdown" //check button if (button2 == 0) { oldindex = 2; oldindex2 = 2; //for loop steps through the myTune array to choose indices for tones for (int i=0; i<20; i++) { //index for columns is i div 5 //index for rows is i % 5 index = myTune[i]/5; index2 = myTune[i]%5; digitalWrite(myColPins[oldindex2],LOW); digitalWrite(myRowPins[oldindex],HIGH); digitalWrite(myColPins[index2],HIGH); digitalWrite(myRowPins[index],LOW); //playing the current note of the pre programmed sequence tone(2, myTones[myTune[i]], (durations[i]*2)); delay (durations[i]*2); oldindex = index; oldindex2 = index2; //Serial.println(index2); } //clears last light from tune sequence digitalWrite(myColPins[oldindex2],LOW); digitalWrite(myRowPins[oldindex],HIGH); }}
== ''Field Research Listed Below'': ==
57
edits