My Mousey Game: Scratch Collisions

30 Apr

This is a first!  I’m typing this blog post ON MY RASPBERRY PI!

 

A while ago, I was just playing around on the Scratch website when i found a pretty interesting  game. The point of the game was to make this little stick figure guy (or girl) get to these doors. In the game you had to cross over these platforms to do tasks. When playing the game, I realized that it was REALLY fun and thought that I would do something similar but with a little kiddy flare to it. so I started to think what could i do to make it fun yet different. After taking some time to think about something popped in my head, ” Why don’t i just make a maze,” ,but than I thought, ” What if it was a mouse going to… what… how about CHEESE!!!” 

The thing that I really learned in doing this project is collisions.  I learned how to do something when two pieces touch.  This worked two places.  First, I had to end the game if mousey touched the outside of the maze (the black part).  At first, I did this by saying, “If mouse color is touching black” but this made the maze too hard because of the way that the mouse turns around corners.  So, instead, I changed it so that the gray ears have to touch the black color.  This is better.

Second, was when the mouse touches the cheese.  So, I also made is so that when mousey’s ears touch the yellow cheese, the game ends and says “Congratulations, you are a winner!”    The dropper tool is really helpful here because I can just click on the cheese to get its color.

Enough talk, I want you to play!  Here’s the link to my game.  http://scratch.mit.edu/projects/krystal92586/3227321 

 

Science Fair Results

21 Apr

Hey, just wanted to let everyone who wished me good luck in the science fair how I did.  I had some trouble this year because I started one project in a professor’s lab and he left and I didn’t get far enough along to turn it into a project.  Then I started another one, but couldn’t get the last ingredient, liquid nitrogen.  So, I didn’t have much time left for my third project.  So, I won the district science fair and got a bronze medal at the county fair.  I also qualified to participate in the Broadcom Masters competition where I can win a trip to Washington D.C. and meet the president.

And then today, I used one of my old projects to enter into a city-wide science fair.  I won third place and won an iPod Shuffle!  That’s pretty cool.  It’s already loaded up with science podcasts.  I LOVE the 60-Second Science series from Scientific American Magazine.

Thanks for all of your good luck wishes.  Next year, I plan to go to the state fair!

Scratch Programming: Meet Winky!

26 Mar

Scratch, what is Scratch?  I’m glad you asked (kind of).  Scratch is an amazing program on my Raspberry Pi.  It came with the Raspbian Wheezy Linux that I installed.  It’s so simple and fun that I want to experiment with it every day.  Most nights, I spend the last half hour before bed learning more about Scratch.

You can download Scratch for a Windows, Mac, or Linux computer and you can also put it on your Raspberry Pi if it’s not already there.  Also, they are beta testing version 2.0 and you can use it online even from a Chromebook or netbook.  Unfortunately, you can’t save your files online, but you can download them to your computer to work on later.

Scratch is a programming language but you don’t need to memorize code.  Instead of creating a while loop, you just drag a “forever-if” block onto the stage.  You just type a couple of numbers instead of a lot of code.  There are blocks to show/hide the character, move him, detect collisions, do math, draw shapes, keep score, and more.  With all of these blocks, you can create games, videos, animations, RPGs, classic video games, and anything else your brain can imagine.

Then, you can upload your Scratch projects to share with the rest of the world.  Or you can see what other brilliant people have done with Scratch.  Just go to http://scratch.mit.edu There are more than 3 million projects there already!

I have an ebook called Super Scratch Programming Adventure.  It teaches you how to do great projects.  Sometimes I struggle, though, because it doesn’t give you all of the details and you have to figure some things out by yourself.  A couple of times, I’ve wasted a lot of time doing it wrong and I don’t figure it out until later.  Like one time, I spent hours drawing these new costumes and it turned out that they were supposed to be sprites.  Luckily, my dad got on the Google+ Scratch page and asked for help and the nice people helped us figure out how to convert costumes to sprites.  Then my Linux got corrupt and I had to reinstall and I lost everything anyhow.

So far, I’ve uploaded one project to the Scratch website.  I was using a Scratch tutorial that was teaching how to move the usual cat character, Scratchy, around the screen.  I decided to change it to a fish and change the background to an aquarium.  The tutorial helped me move him in the shape of a star and drop a pen to make him draw a star.  My dad wasn’t happy that when the fish moved to the left, he was facing to the right and it didn’t look realistic.  So, I figured out how to tell when he’s moving left and made him face left and when he’s moving right and made him face right.

But that wasn’t cute enough for an 11 year old girl, so I had to add my own touch to it.  I added some animation to make my fish (named “Winky”) wink after he drew the star.  All I did was color in his eye with the same color as his body (my dad had to teach me what the eye dropper does) and then draw a black line.  Even though it’s just an eye and then a line and then an eye, it really looks like he’s winking!  OK, enough talk, let me show you my new pet . . . Winky!  Oh, yeah, I almost forgot.  I also made the star rainbow colored!  Awesome!!!  http://scratch.mit.edu/projects/krystal92586/3178144

Here’s a simple tutorial on the basics of Scratch:

Installing Minecraft on my Pi!

11 Mar

Wow, nothing is easy in Linux, is it???  Today, I tried to install Minecraft on my Pi and the directions sounded easy enough.  But, it took me way over an hour to complete.  First, my wifi wouldn’t connect.  I tried 50 times, rebooted 10 times, typed the password in 100 times and it wouldn’t work, just kept saying something about a four-way handshake and a supplicant* (whatever that is) and then started over again in an endless loop.  Finally, just as I was typing in a request for help on the raspberrypi.org forum, it just started working!

 

So, then, I followed the directions exactly to install Minecraft and guess what . . . it didn’t work!  I kept getting EOF errors that were “unrecoverable.”  I tried again and again and again and it just wouldn’t work.  So, I read online about a guy who had to download and delete the file four or five times before it finally worked.  It took me seven times, but finally when I typed “tar -zxvf minecraft-pi-0.1.1.tar.gz” the screen lit up with text and I squeaked a little bit with excitement.  I typed “cd mcpi” and then “./minecraft-pi” and it worked!!!  My dad was sitting with me and heard me get excited about everything that it said on the screen.  I yelled out “It’s building terrain!” and “It’s saving chunks” as the words popped up.

Here’s a picture of my screen:

Image

I got really excited when I realized that it’s the full version of Minecraft, not the lite version that I have on my iPod.  I quickly realized how the controls work: “w” to walk forward, “a” to walk to the left, “s” to walk backwards, “d” to walk to the right, and spacebar to jump.  Pressing “e” takes you to the inventory of all of your supplies.  Also, the left click on the mouse breaks blocks, the right click places things, and the scroll wheel moves through your on-screen inventory.  It scared my parents to see how excited I was about having dynamite in my inventory!  This is sooooooooo much fun!

 

Here is where I got the instructions for installing minecraft on my Pi: http://pi.minecraft.net/

 * “Failed to enable network in wpa_supplicant configuration” 

Here are instructions how to install Minecraft for Pi even if your Pi is not connected to the internet:

 

Raspberry Pi and Wifi

16 Feb

The doorbell rang and I ran to open it.  I peeked through the window and saw a small box.  It said Adafruit on it so I knew my items had arrived!  My mom ordered for me a wifi dongle and an analog to digital converter.  While waiting for the converter, I realized that it’s too complicated for my skill level right now so I decided to work with the wifi first.  Since I got my Raspberry Pi, I’ve had to choose between connecting it to the internet or connecting it to the TV because they’re too far apart for the cables to reach.

So, I plugged in the wifi and turned on the Pi.  I realized that the version of Linux that’s on one of my memory cards doesn’t have the wifi config program on the desktop and I searched everywhere for it and couldn’t find it.  So, I googled how to set it up.  The first instructions had me go into a file and add my wireless username and password and the use ifconfig to see if it was connected.  It wasn’t.  So, I put in another memory card that has a different version of Linux on it.  It has the wifi config on it.  I followed the steps on the Adafruit website EXACTLY and . . . it didn’t work.  Everything worked until the very last step and when I clicked the “connect” button, it just said “scanning” for about an hour.

Next, I called my dad in to try things.  The only setting that we really had any control over was the type of wifi security.  So, we went through each one and none of them worked.  In reading, we found out that the type of security our wireless was using wasn’t the best anyhow.  So, we changed it from WEP to WPA2.  I don’t know what that means, but we read that it’s better.

It worked!  I was connected and I could get on the internet on my RPi while connected to the big TV in the livingroom.  I was disappointed to find out that I can’t watch youtube videos, that’s one of my favorite websites for crafts, music, bloopers, and how to fix stuff.  I read that openelec can connect to youtube and I have that on a different memory card.  So, I put that one in and after quite some time trying different things, I came across a website that had simple instructions that actually worked even though I read about a lot of people who couldn’t get it to work.  Here’s the website that I found useful, http://mymediaexperience.com/openelec-with-wifi-on-raspberry-pi/  I still don’t know how to do anything with wireless on openelec.  Now that it’s online, I see “add-ons” but none of them will install when I click the install button.

The best thing about my new setup is that I can now be online while connected to the TV with an HD cable.  I don’t get the buzzing sound anymore like when I was connected with the red/white/yellow cable.

Then came that horrible call of my mom saying, “Bedtime, turn the TV off!”  So, I had to go to bed.  I’ll play with it some more later and let you know how it turns out.  But for now, I’ve connected Wheezy and openelec through my wireless connector.

This is hard work.  I was hoping to be building 3-D printers run by my RPi by now.  I guess I set my goals too high.  But if anybody has a 3-D printer that they’re not using anymore, I’d be happy to figure out how to make it work ;-)

Here’s a video with instructions on setting up wifi.  This didn’t work for me, but maybe it’ll work for you.

 

 

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

Raspberry Pi and the Science Fair

31 Jan

This will be my third year participating in science fair.  So far, I’ve won at the school and district and I’ve won medals at the county science fair the first two times.  This will be the first year that I can go to the state science fair!  “What should I do for my science fair project?” I wondered to myself.  I’d love to use my Raspberry Pi!  My dad showed me a “Sound Pressure Meter” that he has to measure how loud sounds are.  I wish I could turn my RPi into one of those and enter it into the Computer Science and Mathematics category.

I have a couple of USB microphones, but I don’t know how to connect to USB in Python.  So, I could connect a small microphone to the GPIO pins, but I think I’d need an analog to digital converter to do that.  I’d like to light a small LED if the sound level gets too loud.  Then, I can go around and test bus stops, bathrooms, school concerts, and headphones to see if they’re hurting our ears.  Also, I think that once I did this, then I could replace the microphone with a digital thermometer, Geiger counter, magnetic sensor, gyroscope, and other things using very similar programming.

I just ordered my mcp3008 analog to digital converter from the Adafruit store (https://www.adafruit.com/products/856).  I also snuck a wireless usb device in there too.  Right now, my TV is too far away from my router to be on the internet and on graphical Linux at the same time.  So, I either have to be online and ssh from the laptop to command line or connect to the TV and not have any internet access.  That’s a pain!  Now, I can be graphical and online at the same time!  I can’t wait for them to arrive!

What advice do you have for me as I work on my project?  What tutorials do you recommend?

Follow

Get every new post delivered to your Inbox.

Join 32 other followers