Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!

John Park hacks a Wii controller and turns it into a personal flight recorder that can sense and measure the stomach-churning G forces of roller coasters and other high-speed, high-risk activities.

Download the PDF for this project.

Download the Personal Flight Recorder program for the Arduino.

Get the m4v, subscribe in iTunes, watch on YouTube or Blip.


Related

Comments

  1. RB says:

    I thought I read somewhere, a long time ago, that amusement parks frowned on g-force measuring equipment because they felt the measurements were “secret”…

    1. Glen says:

      ok so now we need a way to capture this data then a Make project that covers bulign a “chair on hydraulics” that mimics the movements from the captured data

      Combine that with the camera footage you recorded and hey presto Coaster-Sim !
      :-)

      1. John Park says:

        Glen, awesome! We actually did make a second version that captures the data to a SD card, along with GPS data. You build the chair, I’ll send you the data. Deal?!

        1. dale says:

          Is there somewhere I we can find the code for the version that records the data to an SD card? Thanks!

  2. Anonymous says:

    Is this the episode that JEP’s ears and eyelids start flapping because of the shear speed of the ride?
    —-I love this episode!…

  3. John Park says:

    RB, that wouldn’t surprise me, but they can’t frown at that which they cannot see, right? :) If wear it around your waist and tie a sweatshirt around it you ought to be fine. Not that I’m endorsing this should they decide to haul you off to the amusement park prison…

  4. DanThompson says:

    Awesome stuff John! (and everyone else involved) I can’t get enough of this show. I wish it was on free to air TV in Australia. Or even cable for that matter! This show just keeps getting better and better! Well done.

  5. Anonymous says:

    In the video it says that the lcd has three wires. Most have many pins. The Vss pin goes to ground (black wire) the Vdd pin goes to the +5V (red wire). Where does the Yellow Wore go?

  6. John Park says:

    That’s an excellent question — you’re right, most common 16×2 LCD screens (like this $14 one: http://www.sparkfun.com/commerce/product_info.php?products_id=255) are parallel and have seventeen thousand wires coming off of them (or ~11 to 14). The most esteemed Ladyada Limor Fried has a nice tutorial on hooking one up here: http://www.ladyada.net/learn/arduino/lcd.html

    I didn’t want to eat up that many pins on the Arduino because I wasn’t sure how many would be needed for everything else when I started, so I took the easy route and ordered a serial LCD that sends all the data over a single wire for $25: http://www.sparkfun.com/commerce/product_info.php?products_id=461

    This was plugged into pin 7 on our project, but any digital pin would work depending on your sketch.

    I look for these types of shortcuts a lot these days because my time is so limited. If I can cheat a little and make things go quicker for an $11 premium I’m all for it!

  7. John Park says:

    That’s an excellent question — you’re right, most common 16×2 LCD screens (like this $14 one: http://www.sparkfun.com/commerce/product_info.php?products_id=255) are parallel and have seventeen thousand wires coming off of them (or ~11 to 14). The most esteemed Ladyada Limor Fried has a nice tutorial on hooking one up here: http://www.ladyada.net/learn/arduino/lcd.html

    I didn’t want to eat up that many pins on the Arduino because I wasn’t sure how many would be needed for everything else when I started, so I took the easy route and ordered a serial LCD that sends all the data over a single wire for $25: http://www.sparkfun.com/commerce/product_info.php?products_id=461

    This was plugged into pin 7 on our project, but any digital pin would work depending on your sketch.

    I look for these types of shortcuts a lot these days because my time is so limited. If I can cheat a little and make things go quicker for an $11 premium I’m all for it!

  8. zack says:

    ok i have all the parts, but two things lie in my way… a LCD screen i dont know how to wire it has 14 holes for wires, three of wich are squares, i bought it from fungizmos.com and the WiiCosterUI when ever i try to upload the program it gives me an error code as seen below

    23: error: LCDSerial.h: No such file or directory In function ‘void setup()’:
    In function ‘void loop()’:

    exactly as you see it above is what i get in the black box in the IDE window. the ardunio is not broken, i tried some exapmle sketches and they work. any help any one can offer would be great!

    -Zack

    1. Make: television says:

      @zack, the estimable John Park has already answered your first question. If you scroll up a comment or two, you’ll find this link (http://www.ladyada.net/learn/arduino/lcd.html) to a nice tutorial on how to hook up your LCD screen.

      To answer your second question, I suspect that the error could be caused by having incorrectly hooked up your LCD screen. But I’ve notified John of your comment, and he’ll have a better idea than I do about how to fix that.

    2. Tod E. Kurt says:

      Hi Zack,

      Here’s the steps I use to get WiiCoasterUI working:
      1. Download WiiCoasterUI.zip from the link at http://blog.makezine.com/archive/2009/02/personal_flight_recorder_program_fo.html
      2. Unzip WiiCoasterUI.zip to a directory (don’t use Window’s ability to double-click into a zipfile like a folder, actually extract all the files)
      3. Go into the WiiCoasterUI folder. You should five files, one of which is “WiiCoasterUI.pde”.
      4. Open up WiiCoasterUI.pde using Arduino software, version 0015 or above. If you have an older version of the Arduino software, get the latest from http://arduino.cc/
      5. Press the “Verify” button (looks like a play button)
      6. The Arduino software should say “Binary sketch size: 6026 bytes” or similar.
      7. Press the “Upload” button to upload to your Arduino board.

      Now until you have the Sparkfun Serial LCD, this Arduino sketch won’t be of much use to you.

      (Aside: this sketch does some kind of advanced tricks with I2C to talk to the Wii Nunchuck. It doesn’t use the standard “Wire” library to talk I2C. This was because it was part of a larger project that needed to be as small as possible)

  9. zack says:

    Ok so your telling me that I have to use the sparkfun LCD and only the sparkfun LCD for the code to work? Why? By the way i have pressed the verift button, i got the same message.

    -Thanks

    1. Tod E. Kurt says:

      Your serial LCD might work. You’d have to compare the command set used by it and that used by the Sparkfun LCD. If they are similar enough, the WiiCoasterUI sketch will work. Otherwise, you’ll have to change it in a few places to make it match your LCD’s command set. These are probably pretty small changes, just setting a different command byte for things like “go to position x,y”.

      As for why the sketch isn’t compiling for you, it’s hard to debug your situation without knowing more of your setup. What operating system are you on? What version of the Arduino software are you using? What kind of Arduino board are you using? Are you working from a fresh, fully unzipped version of the WiiCoasterUI sketch? Do you have all 5 files in the WiiCoasterUI directory? Have you gotten any other Arduino sketches to work?

  10. zack says:

    Here is a data sheet for my LCD screen, all I need to know is what pin holes to use. I have never worked with a LCD screen before.

    http://www.newhavendisplay.com/specs/NHD-0216K3Z-FL-GBW.pdf

  11. zack says:

    I am using the Windows version. I am using the Arduino – 0015 Programming Enviroment; with the Ardunio Duemilanove with the ATmega328 chip. I have the WiiCosterUI fully unziped and have the folowing items inside:

    -applet folder
    -Ardunio software
    -WiiCosterUI.pde

    And yes I have tried other sketches and they work fine. Could you possibly tell me what I should change in the code to make this work?

    Thanks
    -Zack

    1. Tod E. Kurt says:

      Hi Zack,

      Ah, there’s your problem. Somehow you only have the one file (WiiCoasterUI.pde) where you should have a folder called WiiCoasterUI with 5 files inside of it. Did you download this zip file:
      http://cachefly.oreilly.com/make/television/09/WiiCoasterUI.zip
      Unzip it and you should have a folder called WiiCoasterUI with 5 files in it:
      - WiiCoasterUI.pde
      - wiichuck_funcs.h
      - twi_funcs.h
      - LCDSerial.h
      - LCDSerial.cpp

  12. zack says:

    Ok, I have those files now…so whay do I do? Copy and paste into the WiiCoasterUI.pde on the Ardunio software?

  13. Tod E. Kurt says:

    Just run the Arduino software, and from within it, open the WiiCoasterUI.pde file. The software should open it and the other 4 files too.

  14. zack says:

    I am sorry to be such a pain, but the links supplied by all these comments and videos/web pages dont work anymore. I click download, it downloads fine, but once i try to extract the files… nothing. No files. Not a single thing. It may be just my computer, but now I cannot do anything.

    1. @ Zack, Sorry, I’m not able to replicate your problem. All of the links are live and the zip file should contain all of the files you need.

  15. Elliott says:

    I am not quite sure what is happening here. I am following all the directions correctly, except I am not using the ThingM adapter just the I2C bus wires. I can get valid data over the console, so I know my WiiChuck data transfer is functioning correctly.

    Where I get the problem is on the LCD (a serial LCD from Sparkfun). When I re-power the board using a 5V supply all I get is invalid character streams on the LCD. I can press the WiiChuck buttons and move the joystick and this stream changes, but it is still an invalid data stream.

    Any thoughts?

  16. zack says:

    i got it to work again, the link that is. but i am still having trouble with the code.

  17. TXTCLA55 says:

    i cant get it to work either. code is broken.

  18. John Park says:

    Zack, are your code troubles with changing things to work with your particular serial LCD?

    1. dale says:

      John,
      Please see my reply to Zach about the code not compiling. Any suggestions?

  19. Jim says:

    Great tutorial! Just out of curiosity, what program did you use to display the output of the wii nunchuck when you demo’d it in the video? (It showed a graph of the G-force output)

    Thanks

  20. John Park says:

    Thanks, glad you liked it! I used the excellent, open source Darwin Remote software to do the visualizations on my trusty 12″ G4 PowerMac. You can download it here: http://sourceforge.net/projects/darwiin-remote/

  21. Zack says:

    I dont know; I have had problems galore on this project….it seems to be one error code after another. Plus I cant even wire my LCD screen as directed by ladyada mainly because I never did anything like this before. The main error code I get now when I try to verify the code is as follows:

    C;\DOCUME~1\Zack\LOCALS~1\build12989.tmp\/wiichuck_funcs.h: In function ‘void wiichuck_setpowerpins()’:

    C;\DOCUME~1\Zack\LOCALS~1\build12989.tmp\/wiichuck_funcs.h:60: error: ‘PC3′ was not declared in this scope

    C;\DOCUME~1\Zack\LOCALS~1\build12989.tmp\/wiichuck_funcs.h:60: error: ‘PC3′ was not declared in this scope

    1. dale says:

      I’m having exactly the same problem as Zack above (with the code–my LCD is working fine and displays WiiCoaster (only)) It seems that something has changed in the arduino toolset that is causing the program to not compile. If I change the lines where PC2 and PC3 are being used in the define to 2 and 3 respectively (since that is what the ultimately defined as) I can get the code to compile, but when I run it the wiichuck_begin routine blocks in the call to twi_writeTo. Any suggestions, please? I suspect that the problem is deeper than just the definitions of PC2 and PC3, since I assume that at one time the project did compile correctly?

      1. John Park says:

        Dale and Zack, I’ll give this a shot as soon as I can and see if I get any compile errors.
        -John

        1. ec says:

          I have an arduino duemilanove atmega328, and I cannot upload the sketch with arduino 1.0 please help

      2. John Park says:

        Here’s what Tod says:

        “Yeah there’s a small bug in avr-gcc when using an ATmega328. It’s really annoying. They left out all the PCx defines. Change “PC2″ to “PORTC2″ and “PC3″ to “PORTC3″ and it’ll work.”

        1. dale says:

          John,
          I explored this problem a bit more. It does not appear that the code was ever successfully working with a Duemilanove with an ATmega328. Not only is there the compliation problem with PC2 and PC3, but in twi_funcs.h there is a #if defined statment that needs to have __AVR_ATmega328P__ added to it.

          Even after I fix the #if define line, however, I still find that the code hangs. It hangs on the line of code in twi_writeTo() that reads:
          TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);

          I put a Serial.print before and after this line and the second Serial.print never happens.
          Any help with this would be greatly appreciated.

          1. dale says:

            I will answer my own question. It is true that the code provided does not work with a Duemilanove with an ATmega328. I replaced the wiichuck_funcs.h and twi_func.h with code that uses the standard wire library (from Tod Kurt at http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/ and it worked after changing the names of the routines.

            I still have one question: The code has some fragments for “Record” mode. Where can I find some code that will record the data onto a flash USB (or other) drive?

          2. John Park says:

            Hi, yes, we’ll try to resurrect the record-mode code and post it soon. We had it writing out to an SD-card along with GPS data on an Adafruit GPS shield.

          3. dale says:

            I’ve enhanced/modified the WiiCoaster code in the following main ways:

            1) Added the ability to log data to an SD card in a .csv format that can be read (and plotted) by excel. I used this SD Shield:

            http://www.seeedstudio.com/depot/sd-card-shield-for-arduino-v21-p-492.html

            The library used for logging is the latest fat16 library which can be found here:

            http://code.google.com/p/fat16lib/

            2) Enhanced the LCDSerial routines to optionally supoprt the 20×4 LCD.

            3) Added some code that allows you auto-calibrate a particular nunchuck.

            4) Used the standard wire library.

            5) Restructured the code slightly.

            If you are interested you can find my version of the code here:

            http://cid-7d5526f0f2954f33.skydrive.live.com/self.aspx/.Public/WiiCoasterUI.zip

  22. dale says:

    John,
    I changed the definitions as you suggested and it now compiles (as it did when I just used the constants 2 and 3 instead of PC2 and PC3). However after loading the program onto the board it still blocks in the twi_writeTo call in wiichuck_begin(). I put a Serial.print() before and after this call and viewed the output in the Serial Monitor on the PC. The first print shows up, the second one never does. The power and ground are present on Analog pins 2 and 3 as expected. I’ve tried with two different WiiChuck that both work with a Wii. I’ve verified that the WiiChuck is plugged into the adapter board correctly. Any idea how to figure out why the wiichuck is not initializing?

    Thanks!

    1. dale says:

      This appears to have been caused by an incompatibility between the custom wire library and what’s needed on a Duemilanove with a ATMEGA 328. I fixed this by changing the code to use the standard wire library.

  23. skylar says:

    Hey, Im having a problem with my build. I have everything working except for the LCD. This is the one I have: http://www.sparkfun.com/commerce/product_info.php?products_id=9395

    When I turn the Arduino Atmega 368 on, the LCD just displays “WiiCoasterUI”. It is not effected by the Wii Nunchuk at all. Help?! I even changed the PC2 and PC3 in the code to PORTC2 and PORTC3.

    1. dale says:

      I’ve seen this happen in the original version of the WiiCoaster code when the nunchuck is not connnected or initialized properly. You might try my version which is discussed in a reply above and can be found here:

      http://cid-7d5526f0f2954f33.skydrive.live.com/self.aspx/.Public/WiiCoasterUI.zip

In the Maker Shed