For this project, one partner and I were tasked with making something artistic in a electronic way using arduino boards. To do this, we had to complete a series of tasks including making an LED flash, making a song play on a buzzer, and controlling an LCD display. My partner and I decided to make a circuit which involves a buzzer playing the James Bond theme and powering lights configured to show "007".
Code required for this project:
#include "pitches.h" //gives the notes pitches to play at
#define NO_SOUND 0 // make the rests in music
//array of notes
int melody[] = {
NOTE_G4,NOTE_G4,NO_SOUND,NOTE_G4,NOTE_G4,NO_SOUND,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,
NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4, //notes of song
//Introduction
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_DS5,NOTE_D5,NOTE_B4,NOTE_A4,NOTE_B4,
NOTE_E4,NOTE_G4,NOTE_DS5,NOTE_D5,NOTE_G4,NOTE_B4,
NOTE_B4,NOTE_FS5,NOTE_F5,NOTE_B4,NOTE_D5,NOTE_AS5,
NOTE_A5,NOTE_F5,NOTE_A5,NOTE_DS6,NOTE_D6,NO_SOUND //notes of song
};
// note duration: 1 = whole note, 2 = half note, 4 = quarter note, 8 = eighth note, etc.
int noteDurations[] = {
8,8,2,8,8,2,16,8,16,8,8,
2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,2,8,8,1,
8,4,8,4,8,8,
8,8,4,8,4,8,
4,8,4,8,3 //how long each note plays for
};
int pace = 1450; // change pace of music("speedy")
void setup()
{
for (int Note = 0; Note <97; Note++) //counter of Notes (54 limit the array)
{
int duration = pace/noteDurations[Note];//Adjust duration with the pace of music
tone(13, melody[Note],duration); //assign pin 13 to the buzzer
// to distinguish the notes, set a minimum time between them.
delay(duration*1.2);
}
pinMode(12, OUTPUT); //assign a row of LEDs to that pin #
pinMode(11, OUTPUT); //"
pinMode(10, OUTPUT); //"
pinMode(9, OUTPUT); //"
pinMode(8, OUTPUT); //"
pinMode(7, OUTPUT); //"
pinMode(6, OUTPUT); //"
pinMode(5, OUTPUT); //"
pinMode(4, OUTPUT);
}
void loop()
{
digitalWrite(12, HIGH); //turn on that row of LEDs
digitalWrite(11, HIGH); //"
digitalWrite(10, HIGH); //"
digitalWrite(9, HIGH); //"
digitalWrite(8, HIGH); //"
digitalWrite(7, HIGH); //"
digitalWrite(6, HIGH); //"
digitalWrite(5, HIGH); //"
digitalWrite(4, HIGH);
}
#include "pitches.h" //gives the notes pitches to play at
#define NO_SOUND 0 // make the rests in music
//array of notes
int melody[] = {
NOTE_G4,NOTE_G4,NO_SOUND,NOTE_G4,NOTE_G4,NO_SOUND,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,
NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_B3,NOTE_G3,NOTE_C4,NOTE_G3,NOTE_CS4,NOTE_G3,NOTE_C4,NOTE_G3,
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4, //notes of song
//Introduction
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_F4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_E4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_G4,NOTE_E4,NOTE_E4,NOTE_E4,
NOTE_DS5,NOTE_D5,NOTE_B4,NOTE_A4,NOTE_B4,
NOTE_E4,NOTE_G4,NOTE_DS5,NOTE_D5,NOTE_G4,NOTE_B4,
NOTE_B4,NOTE_FS5,NOTE_F5,NOTE_B4,NOTE_D5,NOTE_AS5,
NOTE_A5,NOTE_F5,NOTE_A5,NOTE_DS6,NOTE_D6,NO_SOUND //notes of song
};
// note duration: 1 = whole note, 2 = half note, 4 = quarter note, 8 = eighth note, etc.
int noteDurations[] = {
8,8,2,8,8,2,16,8,16,8,8,
2,4,2,4,2,4,2,4,2,4,2,4,2,4,2,4,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,16,16,8,4,8,8,8,
8,2,8,8,1,
8,4,8,4,8,8,
8,8,4,8,4,8,
4,8,4,8,3 //how long each note plays for
};
int pace = 1450; // change pace of music("speedy")
void setup()
{
for (int Note = 0; Note <97; Note++) //counter of Notes (54 limit the array)
{
int duration = pace/noteDurations[Note];//Adjust duration with the pace of music
tone(13, melody[Note],duration); //assign pin 13 to the buzzer
// to distinguish the notes, set a minimum time between them.
delay(duration*1.2);
}
pinMode(12, OUTPUT); //assign a row of LEDs to that pin #
pinMode(11, OUTPUT); //"
pinMode(10, OUTPUT); //"
pinMode(9, OUTPUT); //"
pinMode(8, OUTPUT); //"
pinMode(7, OUTPUT); //"
pinMode(6, OUTPUT); //"
pinMode(5, OUTPUT); //"
pinMode(4, OUTPUT);
}
void loop()
{
digitalWrite(12, HIGH); //turn on that row of LEDs
digitalWrite(11, HIGH); //"
digitalWrite(10, HIGH); //"
digitalWrite(9, HIGH); //"
digitalWrite(8, HIGH); //"
digitalWrite(7, HIGH); //"
digitalWrite(6, HIGH); //"
digitalWrite(5, HIGH); //"
digitalWrite(4, HIGH);
}
Concepts:
Power(P)- rate of work or amount of energy used per unit time. P = W/t. Measured in watts.
Circuit - a circuit is a closed loop conductive material connected from a positive to a negative side of a power source.
Resistance(R) - a measure of how much resistance the current runs into. In series, resistor values add together, and in parallel, 1/R(total) = 1/R(1) + 1/R(2) + 1/R(3). R = V/I Measured in ohms.
Current(I) - electricity through a circuit. I = V/R. Measured in amps.
Voltage(V) - potential energy drop across a component of a circuit. V= IR. Measured in volts.
Power(P)- rate of work or amount of energy used per unit time. P = W/t. Measured in watts.
Circuit - a circuit is a closed loop conductive material connected from a positive to a negative side of a power source.
Resistance(R) - a measure of how much resistance the current runs into. In series, resistor values add together, and in parallel, 1/R(total) = 1/R(1) + 1/R(2) + 1/R(3). R = V/I Measured in ohms.
Current(I) - electricity through a circuit. I = V/R. Measured in amps.
Voltage(V) - potential energy drop across a component of a circuit. V= IR. Measured in volts.
REFLECTION
Overall, I really liked this project. It was something very different than what I usually expect from our STEM projects. That being said, this project wasn't easy either. Many times my partner and I didn't really know what to do. For example, the coding was a real challenge. We didn't really understand what was going on when we went through the arduino board examples, but my partner stepped up and helped us a lot. As for myself, I think I could have helped out with the coding aspect more. I also could've been less frustrated when I was having trouble understanding complex circuit diagrams. Altogether, I really enjoyed this project.