867-5309
This project was done in pairs of two. It's goal was to program a presentation, that robots could enjoy as art. We started by learning the basics of electricity, then moved to learning about C++ programming language. After we totally understood electricity and programming, we used an arduino red board to program certain tools on a breadboard. My partner and I decided to play the tune of the song 867-5309, Jenny's Number, with an LED light show. We used a number of elements from our electricity learning to create the show.
Concepts
Circuit- a loop of conductive material from one side of a power source to the other.
Voltage- the potential energy difference between two points in a circuit. Use the equation V=ir.
Current- the flow of electricity. Represented by the variable "i", use V=ir
Resistance= an obstacle to current, it slows it down. Resistance is measured in ohms. (V=ir)
Power- the energy transfer rate through a circuit. Use P= iV.
Series- the relationship between components when they are all in line. Voltage is evenly split between components. Current stays the same through the circuit
Parallel- When components are parallel, and the same in relationship to the power source. Voltage is the same through the entire circuit and current splits inversely to resistance. Use the equation 1/total resistance= 1/r-1 + 1/r-2 + 1/r-3 ...
Voltage- the potential energy difference between two points in a circuit. Use the equation V=ir.
Current- the flow of electricity. Represented by the variable "i", use V=ir
Resistance= an obstacle to current, it slows it down. Resistance is measured in ohms. (V=ir)
Power- the energy transfer rate through a circuit. Use P= iV.
Series- the relationship between components when they are all in line. Voltage is evenly split between components. Current stays the same through the circuit
Parallel- When components are parallel, and the same in relationship to the power source. Voltage is the same through the entire circuit and current splits inversely to resistance. Use the equation 1/total resistance= 1/r-1 + 1/r-2 + 1/r-3 ...
Reflection
Going into this project, I had no experience with programming or electricity. Coming out of this, I have a deeper understanding of how electronics work. This project had a slow start, but became much more interesting as we learned about more complex concepts. I also didn't realize how frustrating coding could be at times, but I soon learned some tricks to make it faster. I did well with communication on this assignment. We were allowed to pick our partners, which made communicating easier, and quickened our process. I also did well with empathy on this, by making sure we did a project we could both agree with. I think I could do better with my leadership on the task, by making sure everything was being taken care of in the time we had. I also could be more successful in making more precise explanations for the code. This project was a fun one.
A Copy of the Code
pinMode(6,OUTPUT);pinMode(7,OUTPUT);pinMode(8,OUTPUT);pinMode(9,OUTPUT);pinMode(10,OUTPUT);pinMode(11,OUTPUT);pinMode(12,OUTPUT);}void loop(){int i, duration;for (i = 0; i < songLength; i++) // step through the song arrays{duration = beats[i] * tempo; // length of note/rest in msif (notes[i] == ' ') // is this a rest?{digitalWrite(0,HIGH); // Turns all LEDs off for the beginningdigitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFdelay(duration); // then pause for a moment}else if (notes[i] == '8') // otherwise, play the note{
digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 8-turns on all LEDstone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finishdigitalWrite(0,HIGH);digitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFdelay(tempo/10); // brief pause between notes}else if (notes[i] == '6') // otherwise, play the note{digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);
digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}else if (notes[i] == 'q') // otherwise, play the note{digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}else if (notes[i] == 'r') // otherwise, play the note{digitalWrite(0,LOW);
digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}else if (notes[i] == 's') // otherwise, play the note{digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finishdigitalWrite(0,HIGH);digitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);
digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFdelay(tempo/10); // brief pause between notes}else // otherwise, play the note{digitalWrite(0,HIGH);digitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFtone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}delay(tempo/10); // brief pause between notes}// We only want to play the song once, so we'll pause forever:while(true){}}int frequency(char note){// This function takes a note character (a-g), and returns the// corresponding frequency in Hz for the tone() function.int i;const int numNotes = 20; // number of notes we're storing// The following arrays hold the note characters and their
// corresponding frequencies. The last "C" note is uppercase// to separate it from the first lowercase "c". The numbers are matched up with thecorresponding notes of the song.// For the "char" (character) type, we put single characters// in single quotes.char names[] = { 'c', 'd', 'e','f', 'g', 'a', 'b', 'C', '8', '6', 'm', 'n','5', '3', '0', 'p', 'q', 'r', 's','A'};int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523, 330, 330, 349, 349, 349, 330, 330,294, 330, 294, 262, 220};// Now we'll search through the letters in the array, and if// we find it, we'll return the frequency for that note.for (i = 0; i < numNotes; i++) // Step through the notes{if (names[i] == note) // Is this the one?{return(frequencies[i]); // Yes! Return the frequency}}return(0); // We looked through everything and didn't find it,// but we still need to return a value, so return 0.}
// corresponding frequencies. The last "C" note is uppercase// to separate it from the first lowercase "c". The numbers are matched up with thecorresponding notes of the song.// For the "char" (character) type, we put single characters// in single quotes.char names[] = { 'c', 'd', 'e','f', 'g', 'a', 'b', 'C', '8', '6', 'm', 'n','5', '3', '0', 'p', 'q', 'r', 's','A'};int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523, 330, 330, 349, 349, 349, 330, 330,294, 330, 294, 262, 220};// Now we'll search through the letters in the array, and if// we find it, we'll return the frequency for that note.for (i = 0; i < numNotes; i++) // Step through the notes{if (names[i] == note) // Is this the one?{return(frequencies[i]); // Yes! Return the frequency}}return(0); // We looked through everything and didn't find it,// but we still need to return a value, so return 0.}
Show me more
pinMode(6,OUTPUT);pinMode(7,OUTPUT);pinMode(8,OUTPUT);pinMode(9,OUTPUT);pinMode(10,OUTPUT);pinMode(11,OUTPUT);pinMode(12,OUTPUT);}void loop(){int i, duration;for (i = 0; i < songLength; i++) // step through the song arrays{duration = beats[i] * tempo; // length of note/rest in msif (notes[i] == ' ') // is this a rest?{digitalWrite(0,HIGH); // Turns all LEDs off for the beginningdigitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFdelay(duration); // then pause for a moment}else if (notes[i] == '8') // otherwise, play the note{
digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 8-turns on all LEDstone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finishdigitalWrite(0,HIGH);digitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFdelay(tempo/10); // brief pause between notes}else if (notes[i] == '6') // otherwise, play the note{digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);
digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}else if (notes[i] == 'q') // otherwise, play the note{digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}else if (notes[i] == 'r') // otherwise, play the note{digitalWrite(0,LOW);
digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}else if (notes[i] == 's') // otherwise, play the note{digitalWrite(0,LOW);digitalWrite(1,LOW);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);digitalWrite(12,LOW); // 9tone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finishdigitalWrite(0,HIGH);digitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);
digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFdelay(tempo/10); // brief pause between notes}else // otherwise, play the note{digitalWrite(0,HIGH);digitalWrite(1,HIGH);digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,HIGH);digitalWrite(12,HIGH); // OFFtone(buzzerPin, frequency(notes[i]), duration);delay(duration); // wait for tone to finish}delay(tempo/10); // brief pause between notes}// We only want to play the song once, so we'll pause forever:while(true){}}int frequency(char note){// This function takes a note character (a-g), and returns the// corresponding frequency in Hz for the tone() function.int i;const int numNotes = 20; // number of notes we're storing// The following arrays hold the note characters and their
// corresponding frequencies. The last "C" note is uppercase// to separate it from the first lowercase "c". The numbers are matched up with thecorresponding notes of the song.// For the "char" (character) type, we put single characters// in single quotes.char names[] = { 'c', 'd', 'e','f', 'g', 'a', 'b', 'C', '8', '6', 'm', 'n','5', '3', '0', 'p', 'q', 'r', 's','A'};int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523, 330, 330, 349, 349, 349, 330, 330,294, 330, 294, 262, 220};// Now we'll search through the letters in the array, and if// we find it, we'll return the frequency for that note.for (i = 0; i < numNotes; i++) // Step through the notes{if (names[i] == note) // Is this the one?{return(frequencies[i]); // Yes! Return the frequency}}return(0); // We looked through everything and didn't find it,// but we still need to return a value, so return 0.}
// corresponding frequencies. The last "C" note is uppercase// to separate it from the first lowercase "c". The numbers are matched up with thecorresponding notes of the song.// For the "char" (character) type, we put single characters// in single quotes.char names[] = { 'c', 'd', 'e','f', 'g', 'a', 'b', 'C', '8', '6', 'm', 'n','5', '3', '0', 'p', 'q', 'r', 's','A'};int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523, 330, 330, 349, 349, 349, 330, 330,294, 330, 294, 262, 220};// Now we'll search through the letters in the array, and if// we find it, we'll return the frequency for that note.for (i = 0; i < numNotes; i++) // Step through the notes{if (names[i] == note) // Is this the one?{return(frequencies[i]); // Yes! Return the frequency}}return(0); // We looked through everything and didn't find it,// but we still need to return a value, so return 0.}
Show me more