Minecraft, Programming and the Real World …

I have spent some time over the last couple of years trying to teach the kids programming … for the most part my attempts have been unsuccessful … I was simply not able to interest them.

Recently, my youngest daughter has been (very independently of me)  showing an interest in these kinds of things.  She recently convinced me to help her build a 3D Printer (I will admit she did not have to bend my arm TOO hard) and she has also been asking me the best programming language for a beginner to learn.   (You can see some of our progress with the 3D Printer at this link.)

While helping Helen evaluate a programming language to learn I stumbled across a pretty exciting programming development for Minecraft.  If your kids are at all like two of mine you will already have heard of Minecraft.  If you have not heard about it Minecraft is a real-time game server that allows multiple players to interact together in a virtual world; it is wildly popular.  What I discovered is that the makers of Minecraft have written an interface that allows you to code Python (or Java) to interact with a Minecraft world with scripts that you have written.  They apparently did this specifically to encourage young kids already hooked on Minecraft to learn how to code.

What is really neat is that you can set up this Minecraft/Python programming environment on a Raspberry Pi (a single-board computer) … how cool is that?!  In fact, somebody has already written an introductory, free Python programming ebook that uses this Raspberry Pi/Minecraft combo (called Minecraft Pi) that teaches you how to do things like automatically create a building in minecraft from a python program.

Now, for a totally mind-blowing experience you can take all of this a step further and connect your Minecraft virtual world to the real world.  The beauty of being able to program on a Raspberry Pi is that it is fairly simple to connect the Pi to interface electronics; inputs such as buttons, switches and sensors, and outputs such as LED’s and displays.  Once you’ve mastered some more python programming skills you can cause an action in Minecraft (like moving to a specific location) to do something in the real world (like flash an LED or open your garage door) … or better yet toggling a switch in the real world could cause your Minecraft nemesis to be teleported over a large body of water … your imagination really is the limit.

Sadly, we do not own a Raspberry Pi so I was unable to try some of this out.  However,  you can (and Helen and I did on my Mac and her Windows 7 laptop):

Our really simple first script was:

Screen Shot 2013-11-27 at 6.47.03 AM


It was pretty simple and the free ebook I mentioned earlier looks like a pretty good introduction to programming in Python.  The book is written on the assumption that you are going to use a Raspberry Pi but as I just described you can set this up on any computer and use the book … just ignore the Raspberry Pi stuff.

Getting slightly more complicated I then took a look at talking to an Arduino from a python script (another popular single-board computer used to make things … we are using one in our 3D printer).  It turns out this is pretty straight forward too … I was able to easily blink the lights on an Arduino Uno connected to my computer with a USB cable from a Python script.  This means I could pretty quickly use Python to talk to mine craft and the Arduino (think the real world) at the same time.  I was a little stunned by this … it is fairly easy to put together a Minecraft/Python/single-board computer environment that lets you do a lot of neat things.

There are some amazing possibilities here:

  • Being chased by an angry Minecraft monster?  Run a python script to build your fortress of solitude (in microseconds),
  • Flip a switch in the floor plan of your house that you modelled in Minecraft and watch the light come on in your real house,
  • Press the planetary destruct button you’ve wired to your computer and watch a mine craft world turn completely to water … or disappear.

I am kind-of excited … I feel like I am relating to my kids … sort-of.

First leg of the journey…

Since leaving Darfield on December 16th we have been SO busy!  It is now January 10th and we are in Orlando and I’m just finding time to think about posting.  Part of it was the novelty of being on a true “vacation” again and not wanting to do much else. Another part of our slowness to post was that we were both still working remotely and some of our time in the first two weeks was taken up with setting up our access while on the road. Thankfully Chris was able to do this, but it was an added responsibility that he fulfilled in evenings as his days were spent driving or monitoring the various systems on the van.

Better late than never…

The good news is, that overall, the van performed VERY well.  The stalling issues that presented itself prior to departure, never did get resolved and after a few stressful moments on on/off ramps on the various highways of Canada, Chris and I decided that as it was not a problem at highway speeds, we would use oil only when at those speeds (most of the time) and flip to diesel on on/off ramps and in city/town driving.

We started the trip with a full tank of oil, which we estimate to be 70 litres.  The original tank was 80 litres but to make it fit, Chris had a corner taken off and re-welded.  He has the final measurements of the tank, but again, simply hasn’t had the time to do the simple calculation. So for arguements sake, I’ll stick to 70 litres (although I suspect it is slightly more).

We also packed, on the back cargo basket, 10 jugs of oil.  Ed Beggs, of plantdrive, indicates these are 16-17 litres each. We pre-filtered this oil at home and filled the jugs to the top.  So, add another 170 litres to our departure stock.

Our traditional "good-bye" shot when we leave every three years or so!

The oil on the back weighed just under 500 pounds.  This, with all our gear inside the van, and in the skybox on top, made for a van that looked like it was ready for take-off!  I could definitely feel the weight and because of this, we were more cautious driving. 



Our "stash".

We arrived in Canmore AB the evening of the 16th. We experienced really BAD weather, so it took us longer to drive the 650 kms, mostly because I was driving. I’m one of THOSE drivers in a snowstorm; traffic lines up behind me.  Nevertheless we arrived at our first destination that night in 5 pieces (that would be all of us in one piece each!)

My Carleton journalism friend from way back (I mean WAAAYYY back) had her husband collect oil from the restaurants at Lake Louise, AB, where he works as head plumber on the maintenance team. Maureen and Randy’s efforts allowed us to replenish our tank…and more. In fact we left Canmore with the same amount of oil as we started…plus….three more 17 litre jugs!  Thanks so much Maurren and Randy!  It was also the first time I’d seen Maureen in 20+ years, so I’m thankful used oil brought us together! :)

Fortunately the weather on the 17th cooperated and we made good time across the prairies.  From my estimates, we can run 10km on a litre of oil. So, a tank of oil generally could take us 700 kms. We usually tried to re-fill the tank every 550 litres, as we weren’t sure initially how far the oil would take us.  As we progressed we started to push the limits of the tank.

Chris did start building an arduino sensor to allow us to sense the oil level, and he did hook it up.  It gave us relative readings and he never did find time to add the necessary programming to get it to give us more meaninful readings. 

Chris' arduino oil level indicator. Built from scratch using one of the last plastic containers in our house. A fitting use for it.

Refilling the tank was strange.  Typically we’d stop at a gas station to re-fill. This allowed all of us a bathroom break and to grab a drink if we needed it.  We’d park at the gas station, open up the back of the van, start unwinding our hoses from the pump and start pumping oil from the cargo basket.  At first, we used the charged motorcylce battery we brought, but when that ran down, we connected the pump to the van battery using our jumper cables. In the future we will run a cable underneath the van and have the clamps in the front of the engine compartment.  Feeding the cables through the van and out the window to the battery was not fun!

Stephen was a big help when we had to re-fuel.

Reaction to our re-filling was…non-existant!  Well, we did get some stares as people walked past us, but only ONE person asked us what we were doing and that was the tow truck driver who helped us unlock the van in Strathmore AB (Day 2) when Chris and I managed to lock three sets of keys in the van.

I was disappointed in the reaction. I love to talk about what we are doing. Chris is much lower-key about it, but I think it’s pretty cool, and in reverse I’d be all over it.

Oh well. :)

We were very surprised by how far we went on the initial stock of oil.  My estimate (I clocked the distances on the odometer when we switched to diesel for significant distances). We essentially went 3100 kms on 320 litres of oil.  During that time we filled the diesel tank once (from 1/4 tank to full) as start up and purge times did deplete the diesel.  This cost us about $60.

We ran on diesel from Sault Ste. Marie to just outside of London, ON, where Chris’ brother and sister-in-law live, and where we spent Christmas and a few days after.

Before pic of the Delica in Sudbury. Totally encrusted with Ontario salt.

Andrew and Nancy tried to line-up oil for us prior to us arriving.  Because it needed to settle before we could use it, they tried to find some mid-December.  They didn’t have much luck, being refused at one place outright. Andrew did, however, find somebody selling WVO for $0.89 per litre.

Ugh. Not free, but definitely better than diesel, which was running at a high of $1.42 per litre in northern Ontario.

After picture. :)

Chris did speak to the fellow who was selling WVO, but was put onto another company that collects and sells WVO in bulk (we’re talking in the 10,000 gallons at a time range).  He was intrigued by our oil trip and offered 45 gallons free.

We drove about 30 mins to his collection facility and after an initial reluctance to talk about the WVO business, he opened up and shared.  We had no idea that the industry existed like this, and that it was so competitive. Because the US government has mandated 2% “green” content in its deisel the best way to accomplish this is to convert WVO into biodeisel and add it.  This “green” deisel apparently sells big-time in Europe.  US companies need almost unlimited amounts ofWVO and this fellow, Scott, was collecting from all over Ontario and shipping tanker trucks of it.  Who knew?  Not us!

Because it is so competitive I can’t say Scott’s last name, or what his company is called.  What I can say is that we enjoyed our conversation with him, and were very grateful for the oil.  We ended up filling the tank and only 6 containers, with an eye to what our load would look like when we crossed the US border.

We left London on the 29th and headed into Toronto (on oil again) to visit with our Toronto friends and to show more of the city to the kids. Chris took us all through the University of Toronto and showed the kids where he took Fluid Dynamics when in the Engineering Physics program of the Engineering Department.  We ate on Bathurst Street and went to the AGO (Art Gallery of Ontario) so Helen could see some original Group of Seven paintings (part of her learning plan for homeschooling).  We walked around downtown T.O. a lot.

We left Toronto on January 2nd, full of great memories of the Darbys, Yuyitungs and Hilliers and decided to cross at Kingston. We wanted to use up enough oil before crossing, so that we could disassemble our cargo basket and move the extra oil into the van.  I was worried our unorthodox load would slow us down with too many questions.  We crossed successfully with a full tank and three and half containers in the back of the van.  Most importantly, we left with a full bag of REAL bagels.  :)


We switched to diesel in New Jersey so that we didn’t stall on the nightmare roads that led into NYC and when we left on the 7th we turned back onto oil. We made it to Fayetteville, North Carolina before we moved back to deisel, making a whopping 4800kms of our 6,000 kms trip propelled on WVO.

We’re now in Orlando, and I’ve put feelers out for oil, to no avail. It is our intention to visit friends in San Francisco, so my next project is to line some up in California.  We aren’t fussing too much about it as we are trying to enjoy the trip itself. It’s also easier to stomach the $0.85 per litre cost for deisel here in the U.S.!

I’ve been collecting receipts for costs, but they’ve run away on me. I do know that our accomodation, meals and miscellaneous costs (an emergency buy of electronic device cords, and the $70 break-in-to-the-van-to-get-keys adventure) came to $1,000.  Of that, hotels were $500 (we drove late, and took whatever was in front of us) and fuel was about $175.  Miscellaneous costs were about $200 and the rest was meals and snacks.  At an average price per litre of $1.25 for deisel, we estimate we saved $400 in fuel costs for the first leg of our journey (to Sault Ste. Marie).

Since leaving Canada we’ve spent an obscene amount of money on NYC museums and attractions.  It was worth it.  We did luck out on a hotel in Queens.  Just $114 a night, free parking and breakfast.  NYC was great for the kids. We had so much fun with them, culminating with a night out at the musical, Mary Poppins, on my birthday on the 6th.  The city is amazing, but I am sure that long-term city living is no longer in my future!  Too many people!

Today we purchased a tent and sundry items to put us in camping mode.  Not sure what the plans are after Walt Disney World tomorrow, but I think a few beach days may be in order!

Arduino WVO ECU on a Breadboard!

I understand that most people will not find this post too exciting … but I am excited!

I have been working on an ECU (electronic control unit or more simply computer) for the WVO system.  My current operating schematic (ECU_schem) is as shown in this post.

I finally got some of the parts laid out on a breadboard and tested it this evening … and it worked!  The Arduino controller and circuit:

  1. controlled an automotive relay (turned it off and on),
  2. monitored the variable resistance from the fuel sending unit (in other words read the level of oil in the WVO tank),
  3. and operated off of a 12 volt battery.
Item 3 is actually of the most concern to me right now because being hooked up to a car’s electrical system is actually a pretty harsh environment for the Arduino.  The alternator generates a lot of spikes and noise that can damage the circuit if not accounted for.  I will be curious to see how this part of the circuit works when connected to the running vehicle.  The parts in the circuit dealing with regulating the voltage from the car include:
  • L1 – an inductive coil that is supposed to reduce electrical noise generated by the alternator (the value for this may be off … I was aiming for 40 microH and wound up with a 100 microH part),
  • D4 – A zener diode that should limit voltage spikes to 15V (apparently the alternator can spike up to 20 volts … which would definitely be bad for the Arduino),
  • D5 – A diode to prevent an incorrectly connected battery from damaging the Arduino,
  • U2 – a 9 volt voltage regulator … this is not necessary for the Arduino as it should be able to regulate the voltage provided after D5 … I wanted a constant 9 volts for any analog inputs I add … the analog inputs use a voltage divider to read a value and if this voltage is variable (like what is coming off the battery) the readings will fluctuate,
  • C1-C4 – Capacitors for the voltage regulator U2.
Item 1 was relatively straight forward.  I am using a digital output from the Arduino to turn on a transistor and switch an automotive relay.  An automotive relay is probably massive overkill for what I am doing … but it is definitely safe.  You could also apparently do the same thing with a MOSFET transistor and skip the relay … I was unsure of this so stuck with the automotive relay.  I will need at least two of these circuits to control the two electric WVO valves.  Some notes on the parts used here:
  • R2 is a pull down resistor that guarantees that if the controller is not working the relay will not click on,
  • D2 is a reverse biased diode that protects against a current spike when the relay is turned off,
  • Q2 is an NPN transistor used with an Arduino digital output pin to switch the relay,
  • R1 limits the current drawn from the Arduino pin,
  • The pin labelled 37 on the automotive relay should read 87.
Item 2, the voltage divider, has been tested and works.  I will probably use a smaller resistor here so that I get a larger range of readings on the Arduino anolog input.  I will need at least 3 of these voltage dividers (on 3 separate input pins to monitor temperature, pressure and oil level).
  • R4 is a series resistor again used to protect the Arduino,
  • R3 is the fixed resistor for the voltage divider and I will probably use a smaller resistor here (300-500 ohms?),
  • R5,R6,R7 are the variable resistors for the voltage dividers for the analog readings. (the sending units)
Not shown in the circuit is the LCD display that I connected to the breadboard.  The LCD that I used is pretty generic and I followed the tutorial at http://arduino.cc/en/Tutorial/LiquidCrystal to get it working.  Ultimately, I want to get the Arduino talking to my Android based phone and I think I will use bluetooth for that initially.  I may leave the LCD in so that there is always some interface to the WVO controller if the phone is not in the car … that also means that I should have a few buttons connected to the controller.
The next step is to solder a board and test it in the car … I am getting closer!
The testing code I used on the Arduino is:
// include library code
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

   Proc: lcdInit - Initialize the LCD display
   Returns: initialized LCD object
   Initialize a 16x2 LCD display.  The LiquidCrystal
   library works with all LCD displays that are compatible with the 
   Hitachi HD44780 driver. There are many of them out there, and you
   can usually tell them by the 16-pin interface.
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)


void lcdInit () {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);

  // Print a message to the LCD.


void lcdWriteMessage (String str, int iLine)
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, iLine);
  // print the number of seconds since reset:

 * Notes: 2200 ohm pullup resistor (13 full ; 102 empty)
 *        220 ohm pullup resistor (183 full ; 544 empty)
 *        10 K pullup resistor (1 full ; 22 empty)

int iFuelLevelInput = A0; // a0
int iRelayOutput = 8;     // D8
void setup(void) {
  // Setup the pins
  pinMode(iRelayOutput, OUTPUT);
  pinMode(iFuelLevelInput, INPUT);
  // We'll send debugging information via the Serial monitor

  // Set the levels of the output pins
  digitalWrite(iRelayOutput, LOW);  
void loop(void) {
  int iFuelLevel;
  iFuelLevel = analogRead(iFuelLevelInput);  
 lcdWriteMessage("Fuel Lvl: ", 0);
  lcdWriteMessage("ON ", 1);
 digitalWrite (iRelayOutput, HIGH);
 lcdWriteMessage("OFF", 1);
 digitalWrite (iRelayOutput, LOW);
 delay (1000);