Archive | April, 2013

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. 


Controlling GPIO with Scratch :-)

27 Apr

Today I was continuing with Scratch but it was a little-bit different.  I was trying to control GPIO pins and my breadboard using Scratch.  This type of Scratch was absolutely full of interesting new ideas, possible projects and other worlds of wonder!  If you can control gpio pins, you can do anything! (insert mad scientist laugh here)

The instructions that I followed are found here but they’re a little complicated for a noob like me.  So, I had to look at other pages also to read resistor color codes, find pin diagrams, and use variables in Scratch.

The first step is to install a new version of scratch that has support for GPIO.  Here are the commands.  It’s best to copy and paste them because there are many opportunities to make typing mistakes (this all goes on one line):

sudo wget -O /boot/


sudo /boot/


When you type “startx” and go into Linux, you’ll notice a new version of Scratch (don’t worry, your old version is still there too).  You’ll see some new things.  There’s a block called “broadcast” that will let you turn on a GPIO pin by putting “broadcast pin11high” for example.

So, first, I connected an LED (and resistor) and ran the program that comes with it to blink the LED.  It was pretty simple, turn pin 11 high for one second and then low for 2 seconds.  But I decided that I wanted to use a push button on the breadboard.  The website above talks about inputs a little bit, but I had to go to other pages to figure out how to wire it up.  This one worked for me.

To figure out if the button is pressed or not, you use a “sensor value” block.  I used pin7, so my block said “pin7 sensor value”.  I wanted to put this into an “if” block, but it wouldn’t let me.  So, I put it in a “think” block and I could see that when the button was not pressed, Scratchy would think “1” and when it was pressed, Scratchy would think “0”.  So, I ended up storing the 1 or 0 in a variable called “button” and I used an “if” statement, “if button = 0” to trigger the program when the button is pressed.

Only problem with my little program is that I have to hold the button down.  I might try to make it so that I press it once to start the blinking and again to stop the blinking.

I earlier read about someone who controlled a RC car with the Scratch Programming language and an RPI.  I feel that that is really cool and hope that I could do something like that but with my own nerdy, girly flare to it. Now that I am able to control LEDS…… I CAN CONTROL THE WORLD mwa ha ha, just kidding.

Here’s a picture of the code that I used:


And here’s a video of my dad pressing the button while I click the green flag:

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!