Push-Button Sounds

4 Feb

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:

Image

Advertisements

26 Responses to “Push-Button Sounds”

  1. jonathan ivy February 4, 2013 at 8:47 am #

    wow you are good keep it up

  2. Tim Bryan February 5, 2013 at 12:31 pm #

    Hi, looks like you are having fun! Pin 1 is by the coloured stripe, bottom left as your pic shows, yes all the bottom row are odds, all top row are evens ;o) This page shows the pin orientation Pi-wise (same rules) http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/ I hope that helps!

    • krystal92586 February 6, 2013 at 4:39 am #

      Yeah, that’s the problem. I thought that Pin 23 was the same as GPIO23 and it’s not. I’ll switch them around and see if it works now.

  3. Cody February 6, 2013 at 5:55 pm #

    Too cool! You’re a very inspiring young lady. I can only hope that my daughters will grow up with such drive. Keep it up!

  4. David Munguia February 8, 2013 at 6:26 pm #

    Now you need to get your RaspberryPi to tweet for you!

    • krystal92586 February 9, 2013 at 1:43 am #

      Hey, uncle!! Thanks for the RPi. Can’t wait to get together again so you can teach me some more lessons.

  5. Rob February 10, 2013 at 4:17 am #

    Perhaps this might help with the router….

    http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=30263

    Good luck and keep up the great work!!

  6. Michael Horne February 11, 2013 at 9:17 am #

    Great blog – keep up the good work. Always great to hear what others are up to!

    Mike
    http://www.recantha.co.uk/blog

  7. Bill February 12, 2013 at 6:54 pm #

    I posted some information on the Raspberry Pi forum that I hope helps you with this. Good to see your positive attitude.

    Enjoy!
    Bill

  8. Bill February 12, 2013 at 8:37 pm #

    A little more support for you.

    Since you are using PuTTY for your text interface to the Raspberry Pi, this means you have an ssh server running. This makes transferring files easy. You need to download WinSCP (http://sourceforge.net/projects/winscp/) and install on your WIndows system. This will let you transfer files from your Windows system to the Pi just by dragging and dropping.

    An explanation for “chmod”. First, you could have stayed with your “python sounds.py” method and it would have been fine. Using the “chmod” command to set the file as executable is to reduce the typing required and enable the script to act as a command. The reason this works is because of the “#!/usr/bin/env python” at the top of the script file. The shell interpreter looks at the first two bytes of a file marked as executable to determine the execution method. The magic characters “#!” tell the shell interpreter to use the remainder of the line as the command line for running the script, followed by the script name. So, after setting your file as executable, typing “./sounds.py” is translated to “/usr/bin/env python ./sounds.py” and it runs your script. /usr/bin/env uses your PATH environment to locate the Python interpreter and then calls it with the remaining arguments.

    Enjoy!
    Bill

    • krystal92586 February 13, 2013 at 7:24 am #

      Thanks, that helps. I’ve never used WinSCP, I’ll have to look at it.

  9. Steve Smith February 13, 2013 at 12:23 am #

    Great to see young people getting into Pi. I just bought one today from my local electronics store and although I have been ‘into’ electronics for many years, I’m finding it a challenge. However, I know two things that may help you out.

    First, resistor colour codes. A long time ago, when I was at school, a teacher taught me this: BYE BYE ROSIE OFF YOU GO to BIRMINGHAM VIA GREAT WESTERN. Which is a way of remembering the colours in sequence. 0 Black, 1 Brown, 2 Red, 3 Orange, 4 Yellow, 5 Green, 6 Blue, 7 Violet, 8 Grey and 9 White.

    The other is a way of finding your IP Address on Linux (and Raspberry Pi). Open a terminal window and type ‘ifconfig’ without the quotes and press enter. In the listing, you will spot your current IP Address. Listed under inet I believe.

    I hope that helps. Keep up the great work!

    Steve – @G0TDJ

    • krystal92586 February 13, 2013 at 7:22 am #

      Thanks, that will be very helpful. My problem was that when I’m connected to the internet, I couldn’t be connected to a TV because it is too far away. So, until I could ssh, I couldn’t see what was on the screen to type ifconfig. I just got a wifi dongle, so that should fix it. Now I can connect to the TV and be on the internet.

      • Jorge February 18, 2013 at 3:55 am #

        Ni, amazing work.
        Muy kids are 2 and3 years old, so i just can hope that in 4 more years i could have as much fun as you and your dad.

        For the IP address to be always the same, you need to look at the wireless router for the option static dhcp, this will associate the “MAC address” which is unique for each device to a specific IP.
        Ifconfig -a would proint interface details, the Mac is the value after hwaddr

  10. Trevor Appleton March 4, 2013 at 12:22 pm #

    Great blog, I really enjoy reading it, I love your enthusiasm 🙂
    I was interested to read about your issue with not being able to find you IP address of the Raspberry Pi. I had the same frustrations, having to log into the router to find the new address. However I have found a great way of finding the IP address remotely using a tool called nmap. I have very recently started to blog a little about the raspberry pi and as I have found the nmap tool so useful I have given it its own blog which I released earlier today.
    A link to the blog post is here:
    http://trevorappleton.blogspot.co.uk/2013/03/remotely-find-raspberry-pi-ip-address.html
    I hope you find it useful and keep up the good work!

    • krystal92586 March 5, 2013 at 3:35 am #

      Thanks, I’ll check it out. It’s probably easier than what I’ve started doing . . . I just guess. Only the last number changes so in Putty, I just guess from 1 to 9 until I get it right 😉

      • Trevor Appleton March 7, 2013 at 11:45 am #

        Guessing may work, but the last number can be between 0 and 255, so there are 256 numbers you may need to guess! May take some time 😉

  11. Aaron March 24, 2013 at 2:59 am #

    I know I’m over a month past the date of this post, but thought I could offer some useful information for you. I got my first Raspberry Pi today and have been playing with Raspian. In their package repositories, you can ‘sudo apt-get install tightvncserver’ to install a vnc server, allowing you to remote view the GUI from another computer. After the install finishes, just run ‘tightvncserver’ on your raspberry pi through ssh. This will tell you the ip that the pi is running at, as well as the display number. After that, open your VNC client on your OS of choice, and connect to that ip:display (ex: 192.168.1.100:1).

    There are lots of options when you start the server with the ‘tightvncserver’ command, but this will get your started. You can also set up to autostart the server if you need it all the time. Hope this makes your time with the Pi a little easier!

  12. Alexander Parsan April 12, 2013 at 9:33 pm #

    ” of course, my dad couldn’t remember the password”
    Isn’t that always the way it works!

    • abdullah May 27, 2013 at 11:59 pm #

      hye alex

    • alexander parsan May 28, 2013 at 12:03 am #

      i am loged out of my account and have to use my moom email

      • blueexpert11 August 11, 2013 at 6:12 pm #

        This is not me! Who posted these!

  13. alexander parsan May 28, 2013 at 12:04 am #

    sorry my spellings wrong

Trackbacks/Pingbacks

  1. Push-Button Sounds | Raspberry World - March 11, 2013

    […] By krystal92586 […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: