My visit to the Raspberry Pi’s 5th Birthday Party

Hi guys! CrazySqueak here with another blog post!

Today, I visited the Raspberry Pi’s 5th Birthday Party, and it was awesome! I got to see a bunch of cool projects and even got some new ideas!

Some of the cool projects I saw include:

  • Wizard Chess (From Harry Potter)
  • An giant operation game.
  • Super Mario Bros 3 running from inside a NES controller!
  • A giant “Raspberry Pi Birthday Cake” with Twitter-controlled lights.

After some time looking at projects, I listened to a talk about creating art with Processing by Matt Richardson. The talk was interesting and I got a cool idea from it. I also went to another talk which was about doing Raspberry Jams and that sort of stuff.

One of the best parts was the trivia quiz show. I didn’t do very well but it was still great fun. Afterwards we got to see what was inside the answer buttons’ box, which obviously included a Raspberry Pi!

Also, I chatted with various people such as Grace (HackerFemo’s Mum who does inclusive jams in London), and Philip Colligan (The CEO of the Raspberry Pi Foundation)!

Another great part was that I received a few free gifts from party bags:

  • A Drum HAT (Cool!)
  • A LED strip HAT (I can’t remember the name and nor can Google)
  • And 2 Blue Ducks (I love ducks!)

I’d also like to get a PaPiRus HAT at some point but we’ll have to order one of those online.

Overall, I think the Pi Birthday was amazing and was definitely awesome enough for such an important milestone. I can’t wait for the next one!

Gallery

Text Adventure Prolouge

Hiya guys, it’s CrazySqueak and I’d like to present the first part of my text adventure that I’m working on.

This text adventure is set in minecraft and has many secrets for you to find.

Install instructions

  1. Download the zip file from my dropbox and unzip into a folder that you have write permission for (i.e. a new TextAdventure folder in your home folder)
  2. If it asks you if you want to overwrite/rename/merge files say to overwrite. This way your save data stays intact between installations.
  3. If you haven’t already installed python 3, do it now by downloading it off python.org (windows/mac) or running sudo apt-get install -y python3 (Raspberry Pi)

Run instructions

  1. Go into the folder that you installed the text adventure to and run the program by double-clicking on it (windows) or opening a terminal window in the current folder, typing in the following python3 textadventure.py and pressing ENTER (Raspberry Pi).

Play instructions

  • When it says press enter to continue, do that.
  • When it says select a save file, enter the number corresponding to the save file you’d like to play.
  • If it is a new save file, you will be asked to enter your name, enter your name or enter a different name if you’re trying to find naming easter eggs.
  • When a > appears, type in an instruction and press ENTER.
  • I recommend that you play this game in a maximised window.

This text adventure is like most others in which you have to type the correct instruction to do stuff.

The rest of the game pretty much explains the most important stuff (i.e. Combat, go, inventory, ect.)

I hope you enjoy my game.

Download here.

EDIT: Fixed a line of code that would’ve caused problems later in development.

My Minecraft Minigames

WARNING: This program is not compatible with PC or Python 2: please use a Raspberry Pi and Python 3 to run

Hi readers, it’s CrazySqueak here, I’ve recently exhibited a few projects at Southend Jam and this is one of them.

I’ve written a Minecraft game called McPiWare. The aim of the game is to earn as many points as possible by completing minigames. The minigames occur in a set order and keep coming until you fail at one of them. There is also a bonus round that first occurs when you reach 20 points, and then it multiplies the score required for the bonus round by three each time. You can find a list of the minigames below.

Name Objective Allocated time (secs) Win criteria Bonus points awarded Notes
 Flowers Pick all the flowers  10
  •  The player has picked all the flowers
  •  (0-5) for speed
 Speed bonus is near-impossible to obtain without cheating
 Parkour Land on as many blocks as possible  15
  •  The player has landed on at least five obsidian blocks
  •  (0-any) for each extra block landed on
 Blocks turn to glowing obsidian when landed on, only landing on normal obsidian counts
 Survive  Don’t fall down 30
  •  The player has at least 1 life left at the end
  •  (0-4) for lives left
 The minigame instantly ends if you run out of lives
 Treasure  Find as much treasure as you can  30
  •  The player has found at least 1 treasure block
  •  (0-any) for extra treasure found
 Searching is done by right-clicking grass near cobblestone or farmland while holding a sword
 Miner  Mine as many diamonds as you can  15
  •  The player has mined at least one diamond ore
  •  (0-any) for extra diamonds found
 You will see text in chat when you are near diamonds, diamons are hidden under the layer of stone
 Bonus (aka Path)  Move from the gold block to the diamond block as many times as you can without falling down  15  You complete this minigame no matter what
  •  (0-any) for paths cleared
  • (0-any) bonus points
 Falling down instantly ends the minigame

I’m really pleased with how this game turned out, especially the built in leaderboard which means you can invite your friends over to compete with you. The leaderboard starts with some pre-set scores so it takes a master of the game to achieve the top ranking score.

Feel free to download and share my project but please leave credit to me for creating the original program. I hope it will be included in the next Minecraft Pi hackpack too!

Making my first game that uses the Xbox controller

I’m currently creating a game that uses the Xbox controller. The aim of the game is to keep your rocket ship alive for as long as you can by avoiding asteroids. I’m hoping to finish it in time for a jam that’s coming up soon, so that I can show it off there.

Check out the video below to see it running (as of version alpha_28_01_16):

I will write a new post with the download link after the game is finished.

Hacking an Xbox controller

I’ve managed to use an Xbox controller with my Raspberry Pi. This blog post will tell you about what I’ve managed to do with it and how to do it yourself.

What I’ve managed to do so far

I’ve managed to map the D-pad, and the A, B, X & Y buttons to keys on the keyboard so that they can be used by any application, and create a desktop icon that starts the driver

How you can do it yourself (on the Raspberry Pi)

  1. Type the following into a terminal window to update the cache and install the driver program (press enter after each line):
    sudo apt-get update
    sudo apt-get install xboxdrv
  2. Run this command to remove something that conflicts with the driver (You’ll have to run this once per boot):
    sudo rmmod xpad
  3. Run this command to start the driver and map the keys (You’ll have to run this with your desktop open):
    sudo xboxdrv --ui-clear --ui-buttonmap a=XK_Return,b=XK_Escape,x=XK_x,y=XK_y --ui-buttonmap dl=XK_Left,dr=XK_Right,du=XK_Up,dd=XK_Down

It’d be nice if we didn’t have to enter those two commands every time we wanted to use the controller so let’s write a script to do that for us

  1. Open a new file in your text editor and type in the following:
    #!/bin/bash
    sudo rmmod xpad
    sudo xboxdrv --ui-clear --ui-buttonmap a=XK_Return,b=XK_Escape,x=XK_x,y=XK_y --ui-buttonmap dl=XK_Left,dr=XK_Right,du=XK_Up,dd=XK_Down
  2. Save your file with a name that you’ll remember and recognize as a file for this purpose (like start-xbox-driver)
  3. Type the following in a terminal window to make it executable (replace pathToScript with the path to your script):
    sudo chmod +x pathToScript
  4. You can run the script by typing the following into a terminal window (again, replace pathToScript with the path to your script):
    bash pathToScript

 

I hope this is useful to anyone who wants to get started with using an Xbox controller with their Raspberry Pi and I’ll keep you updated when I do more with it.

How to Hack a Wii Remote (on the raspberry pi)

In this tutorial, I will be telling you how to hack a wii remote. I decided to do this because of a comment:

Mr.Pudding:
Can You Post The Code that you used for it & how to hack or reconfigure the wii remote? That would be awesome!

Preparing

Step 1: Get yourself a bluetooth adapter (you can get one easily from ryanteck) and a Wii remote.

Step 2: Install the required libraries and drivers by typing the following commands into a terminal window:

sudo apt-get update
sudo apt-get install python-cwiid bluetooth

Step 3: Put your pi in discoverable mode by typing the following into a terminal window:

sudo hciconfig hci0 piscan

The code

This will go through each bit of python code to do different things on the wii remote.

Type this in import the library:
import cwiid

Type this in to connect to the wii remote:
wm = cwiid.Wiimote()
Once you run that line of code, make sure to put your remote in discoverable mode by pressing the 1 and 2 keys at the same time.

This line can fail and raise a RuntimeError if it fails to connect to the remote, so you’ll want to handle this and keep attempting to connect until you’re successful

Type this in to tell the wii remote to report back the button state:
wm.rpt_mode = cwiid.RPT_BTN

Press a button and type this in to get its value:
wm.state['buttons']

You can use the values for different buttons later to compare them with the value returned by this code in a program to see if a certain button is pressed.

Type this in to change the current leds lit on the wii remote:
wm.led = replace this value with led value
The led values go up in binary, ie. led 1 is 1, led 2 is 2, led 1 and 2 is 3, led 3 is 4, ect.

Type this in to make the wii remote vibrate:
wm.rumble = True
Replace the value True in the above code with False to make the wii remote stop vibrating.

 

I think that hacking a wii remote is quite easy once you know how to and I really hope this tutorial helped!

Pi Wars

A few days ago, I went to Pi Wars, which is a yearly pi robot competition. I didn’t enter and just went to have a play around with my robot, and see some of the other robots.

My robot was made from a ryanteck robot kit, and you can learn more about my robot here.

I also got some new things including a second distance sensor (I’m planning to stop the pi robot from crashing into things so much), two pi zeros (Pi zeros are miniature raspberry pis, one of them was free with the MagPi, which is a raspberry pi magazine), and some other cool things.

The Pi Zero that came with the MagPi
The Pi Zero that came with the MagPi

Another thing I did is drive my robot on some of the courses that had been set up.
The video below is of my robot attempting to complete an obstacle course.

And this is my robot attempting to bowl:

Also at Pi Wars, I got interviewed by hackerfemo, who has a blog post about this event as well. You can check out his view of the event here.

I didn’t stay until the end of the event, but @whaleygeek managed to get a picture of all the competing robots at the end.

The picture that @whaleygeek took
The picture that @whaleygeek took

Overall, I think that Pi Wars is an awesome event and I hope that my robot will be competing next year. Let’s just hope that my Mum doesn’t try to put as many Lego minifigures on my robot next year – as this year they kept falling off!

Natural Disasters in Minecraft Pi

A meteor strike

Introduction

I have created natural disasters in minecraft using python. It adds many disasters to your minecraft that happen randomly wherever you are in your world. The program randomly starts disasters on it’s own so you should keep moving to avoid getting hit.

The Disasters

Disaster Name Effects Duration Image Extra Info
Earthquake Creates random holes around you. About 1 minute. an earthquake Effects have a range of about 15 blocks from the epicentre.
Sinkhole Creates hole in the ground below you. Instant.  A sinkhole The hole has random edges.
 Meteor Fires a meteor from the sky that crashes into the ground below you. Instant.  A meteor strike The meteor will not stop until it either reaches the highest point of the world at your position or the program crashes.
Meteor shower Fires down 10 meteors that crash into the ground around you. 10 meteors.  A meteor shower The best thing to do when this occurs is to stand still and wait, the meteors from this disaster only rarely crash into you.
Heatwave Causes the area around you to die out. 50 – 90 seconds. a heatwave Only affects wood logs, leaves, water, and grass.
Geyser Creates a column of water that starts at y -60 and ends 5 blocks above the highest point in your world. 25 seconds. a geyser The flood left behind once it ends  takes a while to dry up.
Eruption Erects a massive structure using water and lava. 1 minute and 15 seconds.  an eruption Lava still remains on the inside.

What this code requires to run

Example of how to manually start a disaster

To start a meteor at the position 0, 0 I would use:

meteor(0, 0)

Example of my code

def meteor(x, z):
 mc.postToChat('Meteor approaching!')
 y = 64
 h = mc.getHeight(x, z)
 x -= (64 - h)
 meteorSound.play()
 while y > h:
 y -= 1
 x += 1
 mc.setBlocks(x-2, y-2, z-2, x+2, y+2, z+2, block.OBSIDIAN.id)
 time.sleep(0.05)
 mc.setBlocks(x-2, y-2, z-2, x+2, y+2, z+2, block.AIR.id)
 mc.setBlocks(x-2, y-2, z-2, x+2, y+2, z+2, block.LAVA.id)
 mc.setBlocks(x-1, y-1, z-1, x+1, y+1, z+1, block.OBSIDIAN.id)

the full code is in the download link below

Code Downloads

To download my code click here.

Pi Robot

I have made a pi robot that is controlled by a wii remote. It’s quite slow and doesn’t move straight but I might be able to fix that. I started with a pi robot kit and bluetooth adaptor from ryanteck, a raspberry pi 2, a pi battery, and a wii remote. I learnt how to hack wii remotes from a book called Raspberry Pi Projects for the Evil Genius. This isn’t the finished robot though, I’m planning to add a lego case and some LEDs that act like headlights.

How to use:

  • Once the robot starts spinning, press the 1 and 2 buttons on your wii remote and make sure the remote LEDs stay flashing until either the robot stops or the wii remote starts vibrating.
  • If the wii remote vibrates, you have connected successfully; wait until the remote stops vibrating, then you are in control.
  • If the robot stops and the remote didn’t vibrate, you have failed to connect and you should reboot the pi.
  • Once you are in control, you can use the following controls:
    Button to press what happens
    Control pad Moves/turns in the appropriate direction(as of holding the remote sideways)
    A Lets robot wander until you press B (this automaticly happens when you leave the robot idle for long enough as well)
    plus Releases control until you hold minus for long enough
     B  Lets you choose and run a pre-made program
     –  Enters debug mode, this means that status messages will be printed to the terminal while disabling the actions of A and B. In debug mode, if the robot is idle for long enough, instead of wandering, it will simply release control like you pressed +
    home  Exits the program

Specs

Power required to run pi 5V 1A
Power required for motors 4×1.5V AA battery
Approx. forward speed 8 cm/s
Approx. turning speed 90 degrees/s

Information about the program

The program has been written in two different programming languages, C and python.
The main control program has been written in python and it calls the C programs that control the robot.