Introduction: For our Robot Art Show project, we had to learn imagine and create our very own code. This code should be something creative and unique. Keeping in mind that all students were coming into this project with different levels of Computer Science knowledge, we started off by using the booklet given in the Arduino started kit in order to understand the basic rules of coding. Once kids felt comftorable with the overall concept, they were able to begin their own coding process. My partner and I both had little to none experience with coding, so we decided to keep our project a little more simple. We made a cool looking art show with the song "Hotel California" playing in the background.
int speakerPin = 5; //the pin that buzzer is connected to
void setup()
{
pinMode(speakerPin, OUTPUT); //set the output pin for the speaker
pinMode(13, OUTPUT); // Set pin 13 to output
pinMode(12, OUTPUT); // Set pin 12 to output
pinMode(11,OUTPUT); // Set pin 11 to output
pinMode(10, OUTPUT); // Set pin 10 to output
pinMode(9, OUTPUT); // Set pin 9 to output
pinMode(8, OUTPUT); // Set pin 8 to output
pinMode(7, OUTPUT); // Set pin 7 to output
pinMode(6, OUTPUT); // Set pin 6 to output
}
void loop()
{
digitalWrite(13, HIGH); // Turn on the LED
digitalWrite(6, HIGH); // Turn on the LED
play('f', 1); // Play note F for one tone
digitalWrite(12, HIGH); // Turn on the LED
digitalWrite(7, HIGH); // Turn on the LED
play('f', 1); // Play note f for one tone
digitalWrite(11, HIGH); // Turn on the LED
digitalWrite(8, HIGH); // Wait for LED
play('f', 2); // Play note f for one tone
digitalWrite(10, HIGH); // Turn on the LED
digitalWrite(9, HIGH); // Turn on the LED
play('e', 1); // Play note e for one tone
digitalWrite(13, LOW); // Turn off the LED
digitalWrite(6, LOW); // Turn off the LED
play('e', 1); // Play note e for one tone
digitalWrite(12, LOW); // Turn off the LED
digitalWrite(7, LOW); // Turn off the LED
play('e', 2); // Play note e for 2 tones
digitalWrite(11, LOW); // Turn off the LED
digitalWrite(8, LOW); // Turn off the LED
play('f', 5); // Play note f for 5 tones
digitalWrite(10, LOW); // Turn off the LED
digitalWrite(9, LOW); // Turn off the LED
play(' ', 2); // Play nothing for 2 tones
digitalWrite(10, HIGH); // Turn on the LED
digitalWrite(9, HIGH); // Turn on the LED
play('f', 2); // Play f for 2 tones
digitalWrite(11, HIGH); // Turn on the LED
digitalWrite(8, HIGH); // Wait for LED
play('f', 1); // Play f for one tone
digitalWrite(12, HIGH); // Turn on the LED
digitalWrite(7, HIGH); // Turn on the LED
play('e', 2); // Play e for 2 tones
digitalWrite(11, HIGH); // Turn on the LED
digitalWrite(8, HIGH); // Turn on the LED
play('e', 1); // Play e for 1 tone
digitalWrite(10, LOW); // Turn off the LED
digitalWrite(9, LOW); // Turn off the LED
play('e', 4); // Play e for 4 tones
digitalWrite(11, LOW); // Turn off the LED
digitalWrite(8, LOW); // Turn off the LED
play(' ', 2); // Play nothing for 2 tones
digitalWrite(12, LOW); // Turn off the LED
digitalWrite(7, LOW); // Turn off the LED
digitalWrite(13, LOW); // Turn off the LED
digitalWrite(6, LOW); // Turn off the LED
while (false) {} //play song forever
}
void play( char note, int beats)
{
int numNotes = 14; // 14 different types of notes
//this array is used to look up the notes
char notes[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'D', 'E', 'F', 'G', 'A', 'B', ' '};
// matches each note to the correct type of frequency
int frequencies[] = {131, 147, 165, 175, 196, 220, 247, 262, 294, 330, 349, 392, 440, 494, 0}; // given these frequencies
int currentFrequency = 0; //the frequency that we find when we look up a frequency in the arrays
int beatLength = 500; //the length of one beat (changing this will speed up or slow down the tempo of the song)
//each frequency should correspond to the correct note you want to be played
for (int i = 0; i < numNotes; i++) // check the value in notes from each note given
{
if (notes[i] == note) // do both letters match each other?
{
currentFrequency = frequencies[i]; // Frequency needs to match each note
}
}
tone(speakerPin, currentFrequency, beats * beatLength);
delay(beats * beatLength); //wait for each beat to finnish
delay(35); // a break in between each note
}
Project Working All Together
Circuit Diagram
What is Coulomb's Law?
Force of attraction/repulsion between 2 static charges is proportional to their charges and inverse to the square of the distance
What is an electromagnet?
An electromagnet is a large metal core (battery) covered by coil sending electric current creating a magnet.
Explaining Equations:
Charge: The magnitude of electrical quantity F=K (q1 q2/d2)
Series Circuit: A circuit with only one single path and multiple components Total= r1+ r2+ r3....
Parallel Circuit: a circuit with branches, each with separate paths for charge/electrons to flow 1/Total= 1/r1 + 1/r2 + 1/r3...
Resistance: The amount of current that is slowed or resisted through an obstacle V=ir (r= i/V)
Voltage: The potential energy difference from one side of compact to the others V= ir
Current: The flow of charge throughout the circuit V=ir (i=r/v)
Reflection:
I learned a lot physically and mentally during this project. Physically I learned how difficult and precise coding is. Even if you make the tiniest mistake whether with the actual code itself or when setting up the circuit, the whole project won't work. I learned that coding is a completely different language and you have to learn how to use different starters, inputs, outputs, etc... in order to create the code best needed for what you are hoping to be done. Mentally, I learned how to persevere. How to keep working even when things feel impossible or I just don't have the motivation to do it.
This project was extremely difficult for me. There were many times I felt like we would never get it done and I just genuinely didn't care to put in the effort to try. Until I finally put my head down and managed to make myself really focus in and try to understand the concept. Realizing that it is okay to ask questions and trying to navigate my way through the project. In the end I really seemed to surprise myself with the result of the project. I'm extremely proud of myself for that.
That being said, I did get very distracted during the beginning period of this project. And although I did start focusing more later on, it is still something I need to work on. Making sure to stay on task. Not only that, but also working on time management. I'm usually pretty good with my time management, but with this project we got very time crunched and probably could've added more to our project if we dealt out more time for ourselves from the start.
Other Group Member: Abby Bartholo