Friday, 29 April 2016

Child Study Center Final Project: Week 4

This week, we tried our music shield, our lights, and our servo separately and then attempted to run them simultaneously. While each component worked individually, the combination failed. We figured later that this was because the music maker shield was using the pin we attempted to use for our servo. This means that we either had to use two separate Arduino micro controllers (1 for music only and another for LEDs and a servo motor) or that we had to be extra careful about which pins we used if we were to keep using the same Arduino for all our outputs. Before we hit this hurdle, however, there were a few accomplishments and mini failures we went through.


Soldering the music maker shield:
Because our music maker shield came in pieces, we had to solder the parts according to Adafruit's online instructions. Since solder includes lead, we were careful not to breath in the fume and used a fume extractor whenever we soldered.




We then inserted an SD card with two files of music carefully named to match the format in the code. We had named them incorrectly before this to find that the music doesn't play unless it is named "Tracknnn" where is an integer 0-9. We also needed exactly 8 characters in our name. We connected a headphone to the black port and ran the following code:


The songs played while the serial monitor showed "played." When the music stopped playing, the monitor printed "done playing." Since this worked well, we tried connecting our speaker to the blue ports and ran the code again. While the music played and the serial monitor showed the appropriate status reports, the volume was really low. Circled in the code above is a part that controls the volume. As it is the volume is set to (20,20) and it says that the lower these numbers, the higher the volume. So we ran the code over and over with much lower numbers but still couldn't adjust the volume. 
                                    

We asked for Amy's help at this point and moved on to work on the servo and LEDs.

Servo and LEDs in one:
We used the following code to operate the servo and LEDs together. Because we defined PreviousMillis (the total time that has passed since the program started running) as an integer and not as an unsigned long, we had problems on the second or third rounds of running the system. The value of previousMillis would get stuck and give us only one LED lighting up instead of the expected pattern.


We also had a hard time making the servo stop after a certain amount of time. As we tried to troubleshoot the servo's tendency to never stop running, we learned that we were using a continuous servo motor that keeps increasing its angle with each round. Even as it oscillates back and forth, its net position shifts. This is not ideal for a movement we plan to resemble that of human wrists, because wrists don't keep on rotating infinitely. Once we switched our servo motor to the correct type, we still noticed that the command that tells it to go to a specific position and stay didn't work. Part of our goal for the next week is to work on controlling the servo better.


Lastly, our music maker stopped working after we connected it to our servo. It started reading "done playing music" even when it obviously didn't and we couldn't hear anything from the speakers. This may mean we have erased some data regarding the pins the music maker shield needs to use in order to play music. This could involve adjusting parts of the library and may take lots of time (unrealistic to our timeline), but we have our fingers crossed.




4 comments:

  1. The document process is very clear and easy to follow :-)

    ReplyDelete
  2. really like the idea! even like how you got the serial to print when the music was done playing

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. that's really frustrating how the music file needs to be named something so specific! Y'all look like you're making a lot of really good progress – I wish y'all luck on figuring out what's going on with the servo and music!

    ReplyDelete