More about my documentation (from the Self-regulated Learning perspective!):
Planning Stage:
I have two goals for this project. First, I plan to make the music box play a part of a song that I love, instead of 'Twinkle, Twinkle, Little Star.' Second, I want to make the music box fun or even useful for commercial or educational purposes. So, I sketched out the design and found the sheet music for 'OMG' online. I came up with the idea of turning the music box into an interactive book because I believe this engaging activity might motivate fans to purchase this product.
Next, I scheduled my plan on the calendar. I intend to start this project on Saturday afternoon during TA hours. In case I can't finish the project or encounter any issues, I can return on Sunday afternoon to seek help again.
Performance Stage:
I started modifying Arduino codes on Saturday morning. First of all, I found a music score of "OMG":
Then, I found that the original codes didn't include B3. So, I searched online and define B3 as "define NOTE_B3 247". I mimicked the format of "Twinkle twinkle little star" and modified code as "
char song[] = "cccce cccce eefgcccceB cccce cccce eefgccceed";
int beats[] = {1,1,1,1,2,1,
1,1,1,1,2,1,
1,1,1,1,1,1,1,1,2,2,6,
1,1,1,1,2,1,
1,1,1,1,2,1,
1,1,1,1,1,1,1,1,2,2};
int tempo = 150;
char names[] = {'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'B'};
int tones[] = {NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_B3};
According to the plan, I reviewed the "Adafruit Circuit Playground Bluefruit" document, and started my first try as:
int lightValue;
void setup() {
Serial.begin(9600);
CircuitPlayground.begin();
}
void loop() {
lightValue = CircuitPlayground.lightSensor();
Serial.print("Light Sensor: ");
Serial.println(lightValue);
// if there is little light
if (lightValue < 20 )
// turn the second neopixel on
CircuitPlayground.setPixelColor(1, 255, 0, 0);
else {
// otherwise, turn off all the neopixels and play music
playSong();
CircuitPlayground.clearPixels();
}
}
However, the music played all the way through even if I covered the light. However, the TA hours have ended, so I immediately wrote an email to professor. She told me two things:
1) Increase the 20 value to 60
2) Mode the light sensing code to the playNote are of the code.
I followed these two pieces of advice and went back to Fimbel lab and modified my light sensing codes again:
void playNote(int frequency, int duration) {
if (!CircuitPlayground.slideSwitch()) {
return;
}
else {
lightValue = CircuitPlayground.lightSensor();
Serial.print("Light Sensor: ");
Serial.println(lightValue);
if (lightValue > 60){
Serial.print("if");
CircuitPlayground.playTone(frequency, duration, false);
delay(duration + duration/16);
}
else {
}
}
}
And.. Success!
Reflection Stage:
I reflected on my learning strategies for this music box project on Sunday evening. And I think I did a good job in planning stage. However, I should try to cope with my stress and discouragement when I failed. I unavoidably had fixed mindset when I failed modifying Arduino codes, and I told myself. "See, this is not space for you." This acutally hinders my motivation and willingness to seek for help. (More of my reflection is at the following link...)
Read my reflection! <3
*** Final Codes!