We made every effort to enhance our project by incorporating various elements. We integrated a digital light, a servo motor, and an analog sonic sensor. The aluminum on the side serves as a button to control the light and servo, while the sensor plays piano keys based on the distance of the hand. Despite our numerous ideas, implementing them became a challenge, and we faced struggles with the Arduino that led us to adapt our concepts as we encountered difficulties that proved difficult to overcome. An A foil based heart to controll the tone melody.
void loop() {
unsigned long currentMillisMelody = millis();
// Play the melody
if (currentMillisMelody - previousMillisMelody >= noteDuration) {
previousMillisMelody = currentMillisMelody;
// Check if there are still notes to play
if (currentNote < notes) {
// calculates the duration of each note
divider = melody[currentNote * 2 + 1];
if (divider > 0) {
// regular note, just proceed
noteDuration = (wholenote) / divider;
} else if (divider < 0) {
// dotted notes are represented with negative durations!!
noteDuration = (wholenote) / abs(divider);
noteDuration *= 1.5; // increases the duration in half for dotted notes
}
// Play the note
tone(buzzer, melody[currentNote * 2], noteDuration * 0.9);
// Increment to the next note
currentNote++;
} else {
// All notes played, reset to the beginning
currentNote = 0;
}
}
// Move the servo
// Move the servo from 0 to 360 degrees
if (currentMillisMelody % 30 == 0) { // Adjust the value based on your servo speed
if (pos < 180) {
pos++;
} else if (pos < 360) {
pos++;
} else {
pos = 0;
}
myservo.write(pos);
}
}
Reflection
For improvements, I’d like to achieve what we had in mind but couldn’t accomplish in our project. I would also like to reintroduce the button somewhere in our project since we encountered difficulties in that aspect. Additionally, I’m open to suggestions on how to enhance and refine our project further. However, despite the numerous challenges and occasional breakdowns we faced during the process, we take pride in the final outcome. The journey was marked by struggles, but looking back, I can confidently say that the effort was entirely worth it. The end result exceeded our expectations even if our original plan hasnt been achieved, and I genuinely loved how our project turned out, even though it had its share of difficulties. Throughout it all, we managed to have a fun time working together. Now, I need to troubleshoot my Arduino, as it unexpectedly caused issues with my laptop and even caused some lag on my MacBook. It’s a reminder of the unpredictability that comes with the creative endeavors!