I tried a transistor, but no luck with that. I just made a digital pin the output so that it powers the speaker when the analog input shows that there's enough light past a threshold. I'm going to tape it to the inside of a cookie jar lid, so when you lift the lid it should play
Thanks for the help so far. My only problem is that the arduino will sometimes not get power from the computer, except when I touch the power selection jumper with my finger. Then it starts working. I don't know why...