Today’s blog is going to be a little bit different, instead of me doing my blog after doing something fun, I will be making a device that will play sounds when a button is pushed, and blogging at the same time. It’ll be like Freddy on iCarly! I found this idea on a website, http://learn.adafruit.com/downloads/pdf/playing-sounds-and-using-buttons-with-raspberry-pi.pdf. I thought this would be fun so forget the superbowl and go raspberry pi. I am starting by setting up the bread board, but I see that there are resistors. I have resistors but I don’t know how to read them so I have to learn. I just found this website http://www.michaels-electronics-lessons.com/resistor-color-code.html that makes it easy to understand. According to the instructions I will need three 10k resistors, and I found that the color code is brown, black, orange but I will check it with my multi-meter just to be sure.
My dad explained to me how a bread board works and we just attached the three switches and resistors, it was pretty easy. Now we have to plug it in to my raspberry pi but which way does it go? Thank goodness that adafruit’s website has a picture that really helps. We also have to connect the raspberry pi to the internet and then do the programming from the laptop with “Putty.” I will be right back I have to go plug it in and go connect it. J Something just happened while I was trying to open putty a message popped up and it said that it timed out. Turns out that we could never figure out how to make the router give RPi an IP address and keep it that way. So, we had to log in to the router to find out the new IP address and of course, my dad couldn’t remember the password, so we had to call Verizon (again!) to log in. We still cannot plug it into the internet and a TV at the same time, so we had no way to see the IP address on the PI if we couldn’t connect the laptop to it. That was just the beginning of our problems.
Our next problem was how to get the mp3 files onto the RPi. The Windows computer wouldn’t let us copy and paste onto the memory card because it had been formatted. We don’t know how to get on the internet from the command line and we can’t get on the internet in GUI Linux because our router is too far from the TV (we have a wireless usb device in the mail). So, we finally put the mp3s on a flash drive. Sounded easy, right? It wasn’t. We had to learn how to “mount” the flash drive. That took an hour or two. We used the instructions here, http://elinux.org/RPi_Adding_USB_Drives but they didn’t work. It said to type “sudo mount -o uid=pi, gid=pi /dev/sda1 /mnt/KFD” where KFD is the directory I made to mount my flash drive. It finally worked when we typed
“sudo mount /dev/sda1 /mnt/KFD” and left everything else out.
Then, we had to learn how to copy the mp3 files to the same directory as where we’d save the program. That took some time too. We didn’t know how to link to the KFD directory when were were in the sda1 director or link to the sda1 directory when were were in the KFD directory. Finally, we made a directory where I’m going to save my program and called it “sounds”. I went into the mnt/KFD/Sounds directory and typed “cp laughter-1.mp3 ~/sounds” and it worked! It’s so confusing going back and forth through all of the directories.
Next, we typed the program into vi and saved it. Then we used chmod to make it executable following the instructions. We’ve never done that before, we usually just type “python sounds.py”. The program didn’t work. It kept playing the sound over and over and over even without pressing a button. Pressing the button didn’t do anything. It kept sending this message,
Playing MPEG stream from laughter-1.mp3 …
MPEG 1.0 layer III, 256 kbit/s, 48000 Hz stereo
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
^CTraceback (most recent call last):
File “./sounds.py”, line 15, in <module>
[0:04] Decoding of laughter-1.mp3 finished.
[0:06] Decoding of laughter-1.mp3 finished.
[0:01] Decoding of laughter-1.mp3 finished.
[0:05] Decoding of laughter-1.mp3 finished.
[0:02] Decoding of laughter-1.mp3 finished.
[0:03] Decoding of laughter-1.mp3 finished.
sleep(1);
My ribbon cable is different than adafruit’s, so maybe we didn’t connect the wires right. We’re both way too tired to work on it anymore today. The picture in adafruit’s instructions showed pins 23, 24, and 25 all on the same side. On mine, all of the odds are on one side and the evens are on the other side. I think that might be the problem. Any ideas?
Here’s a picture of my circuit:

Tags: adafruit, alsa, gpio, kid, mp3, project, raspberry pi