I'm Not Texting I'm Programming!

Update: This app is available now as Physics Gizmo on Google Play.

No less than a century ago, it was possible to learn everything we knew about science. The only requirements were an ability to read, an extensive library, and perhaps the equipment to carry out your own experiments. Now we have entered a new era of science where literacy is more widespread and between the Internet and Libraries we have every resource imaginable at our fingertips.

Two big problems remain, science has diversified and grown so much that it is difficult for scientists to know everything about their own field let alone another. The other issue is how science equipment remains financially out of reach of amateurs and explorers. The major scientific research is driven by that which will have a financial return and so science for its own sake is limited. This is even more evident in schools who are cutting science to save the rest of their budgets and focus on less expensive (and more tested) subjects This must change if a steady stream of innovation is to continue.

The hacker spirit is a deeply embedded part of science. Now out of necessity and pure enjoyment, many are directing their attention away from software development but to hardware. In the August issue of Wired, the BioHacker movement features those who wish to reduce the cost of doing Genetic analysis.

Do you know where these DIY Biologists expect to see the most impact? Schools! For students to do science instead of just reading about it. Arduinos, Makerbots, Robotics, and more are forever changing the opportunities students have to create.

At my school we spent a lot of time in labs and projects. What was lacking was quality data. Unfortunately the tools and sensors available to students are expensive and limited. So I did what I always do, I sat down and wrote some code :)

I love my Android phone and each day I hear about the insane number of new activations everyday. The smart phone is getting smarter and cheaper just as technology always does. Just as we saw an explosion of Desktops and later Laptops in the 1990-2000s, we are seeing an even speedier rate of adoption of smart phones. While looking at my phone one day, I realized how many sensors/tools it has built in seamlessly to its interface (Internet, Accelerometer (motion sensor), Gyroscope, Light, Sound) which if purchased separately would be thousands of dollars and would not play well with each other.

So I wrote a program which logs motion and then uploads it to your Google Docs account. You can see some screenshots below of the results.

Jumping up and down

Dropping my phone (onto a pillow)

To do this, I used sl4a (Scripting Language for Android). With this you can code in Python, Ruby, Javascript (and more) and do almost anything with your Android phone. It has a built in editor so you can quickly type code into the phone (hence this post's name) or you can code it in your favorite editor and then transfer it to the SD card on your phone.

Why did I use sl4a instead of making a nice pretty app using Android's SDK? This application uses the Google Doc APIs (basically commands to communicate between an app and and a program like Twitter or Facebook) and Python. If you look at the code it could be done by any of our students with a free weekend. It may look a little complicated at first but there are just a lot of function calls to save code. Just like most other Python code, it reads like a story (login, get the parameters, sense, upload).

I believe sl4a could take students who may or may not have used App Inventor or Scratch to the next level and open up a world of possibilities to them. sl4a has been used to send collect data on a phone being launched into space and many other exciting projects involving Twitter, Robots, Arduino and more!


I wanted to use sl4a so everyone who knows Python could see the code and hopefully improve on it. I don't have the time right now, but I would love to see other sensors added, the ability to review and display the data/graph on the phone, interface with Arduino, and store data on the phone if it logs data longer than 1 minute, and perhaps even add a pretty GUI. I'm hoping that by open sourcing this, others will want to jump on board and help out. Cellbots have set the bar really high and have their own incredible data logging app and if they integrated Google Docs uploading I would say their app is perfection.

My hope is as more educators/students realize their ability to create, scientific tools will become available to all. People like Steve Dickie, the Arduino team, Geogebra, and many others are working really hard to ensure that the cost to do STEM is reduced dramatically.

You could walk into your class on Monday and ask your students how many of them have an Android phone, you may be surprised that there are enough for one per group. Think of all of the experiments you could do with nothing else but your phone. I can't wait for this year's Magic Mountain Physics Day and see how many students could get data from a roller coaster and directly upload it to their Google Docs (and check it while still at the park from the GDocs Android app).

Look how easy it is to make a little popup on your screen!
import android
droid=android.Android()
droid.makeToast("Hello Android")


If you want to give this a shot, go to the sl4a website and download the apk (the installer). Your other options are to click this link, or scan the barcode on the right with your Android phone. Follow the User Guide to get Python (or the other languages) installed on your phone.

Now, you are ready to start coding on/for your phone. There are some great tutorials on the sl4a website, I also recommend the book Pro Android Python with SL4A. In my code below I list a few other resources that were helpful to the doScience project.

If your code is relatively small you can share it via barcode but this app falls just above that threshold. So you can copy and paste it from below (just please respect the Creative Commons licence) into your Python Editor or download the doScience file directly. Save it to your SD card in the sl4a/scripts folder. This code must be run on a phone or a computer connected to a phone running an sl4a server (much simpler than it sounds).

Note: It will ask you to login to your Google account. As you can see from the code below, no one is able to access that information since it is kept hidden from even the developer by the dialogGetPassword method in line 41.

I hope this app inspires you to do something great. If you know how to program, build, create will you please lend your talents to this projects or the many others out there. If you don't know how to create, then learn as it is the most incredible thing to be a Maker and you will inspire others. Before you know it, the revolution will be underway (oh wait it already is, come join us)!

Subscribe and Connect to BrokenAirplane and stay up to date with the best resources for your classroom.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
'''This code is licenced under a Creative Commons
Attribution-NonCommercial-ShareAlike 3.0 Unported Licence.
Created by Phil Wagner 2011 www.brokenairplane.com. This code allows data logging and uploading to Google Spreadsheets.
It exists so students can to do Science when 
the cost of Science Equipment is too expensive. Additional features can be added
but this paragraph should always remain in the code.'''

#Future features - Additional Sensors, Review, Display Data/Graph on Phone
#interface with Arduino/ADK

#Helpful Resources:
#http://code.google.com/p/android-scripting/ (sl4a)
#http://code.google.com/ (Google APIs and resources)
#http://www.adaptcode.com/using-google-spreadsheets-as-a-database-in-the-cloud/
#http://gdata-python-client.googlecode.com/svn/trunk/pydocs/gdata.spreadsheet.text_db.html

import android
import time
import gdata.spreadsheet.service
import gdata.spreadsheet.text_db
import string

droid = android.Android()

dt=100 #Time between sensing

def countdown():
    #3 Second Countdown and Vibrate
    droid.vibrate(100)
    time.sleep(1)
    droid.vibrate(100)
    time.sleep(1)
    droid.vibrate(100)#3 second countdown
    time.sleep(1)
    droid.vibrate(300)
    return

def login(myEmail='example@gmail.com', password=''):    #Get Email and Password and login
    while password == '':
        email = droid.dialogGetInput("Email", "Enter the email account where the Data will be uploaded to:",myEmail).result
        password=droid.dialogGetPassword("Password", "Enter the account password where the Data will be uploaded to:").result
        try:
            client = gdata.spreadsheet.text_db.DatabaseClient()
            client.SetCredentials(username=email, password=password)
        except gdata.spreadsheet.text_db.BadCredentials:
            droid.dialogCreateAlert("Username or password incorrect.")
            droid.dialogSetPositiveButtonText("OK")
            droid.dialogShow()
            redo = droid.dialogGetResponse()
            password =''
            continue
        else:
            return client

def spreadSheetSetup(client, defaultTitle = 'Science Data'):
    versionNumber = client.GetDatabases(name=defaultTitle)
    if len(versionNumber) > 0:
        droid.dialogCreateAlert('Science Data %d' % len(versionNumber))
        droid.dialogSetPositiveButtonText("OK") #Yes option box
        droid.dialogShow()
        understood = droid.dialogGetResponse()
        spreadsheetTitle = defaultTitle+' '+str(len(versionNumber))
    else:
        spreadsheetTitle = defaultTitle
    return client.CreateDatabase(spreadsheetTitle)

def time2Sense(defaultTime=5000):
    maxTime =0
    #Enter time for sensing
    while maxTime == 0: ##How long to sense?
        try:
            maxTime=int(droid.dialogGetInput("Time", "How long to collect data (in milliseconds):",str(defaultTime)).result)
        except TypeError:
            droid.dialogCreateAlert("Please enter a numeric time")
            droid.dialogSetPositiveButtonText("OK")
            droid.dialogShow()
            droid.dialogGetResponse()
            continue
        if maxTime > 30000: #30 seconds max for optimal upload
            droid.dialogCreateAlert("Warning this could take a long time to upload.")
            droid.dialogSetPositiveButtonText("I accept the risks")
            droid.dialogSetNegativeButtonText('New time')
            droid.dialogShow()
            check = droid.dialogGetResponse().result
            if check['which'] == 'positive':
                return maxTime
            else:
                maxTime = 0
                continue
        return maxTime

def doScience():
    droid.dialogCreateAlert('Are you ready', 'Click yes to begin sensing, or no to cancel')
    droid.dialogSetPositiveButtonText("Let's do science!") #Yes option box
    droid.dialogSetNegativeButtonText("Nah let's cancel") #No option box
    droid.dialogShow()
    return droid.dialogGetResponse().result

def senseAccel(endTime,dt=100):    #Sense and store accel data
    timeSensed=0
    tempScience = []
    droid.startSensingTimed(2,dt) #dt = time between sensings
    while timeSensed <= endTime:
        tempScience.append(droid.sensorsReadAccelerometer().result) #add new accel data to list
        time.sleep(dt/1000.0)
        timeSensed+=dt
    #Stop Sensing
    droid.makeToast("Done")
    droid.vibrate(300)
    droid.stopSensing()
    return tempScience

def main():
    db =spreadSheetSetup(login())
    endTime = time2Sense()
    ready = doScience()
    if ready['which'] == 'positive':
        countdown()
        science = senseAccel(endTime,dt)
        table=db.CreateTable('Accelerometer',['t','x','y','z']) #Beware spreadsheet column names cannot be uppercase if you are going to add to them later http://code.google.com/p/gdata-python-client/issues/detail?id=363
        droid.dialogCreateHorizontalProgress('Progress','Uploading to Docs',len(science)*3 )
        droid.dialogShow()
        progress = 0
        time = 0
        for data in science:
            table.AddRecord({'t':str(time),'x':str(data[0]),'y':str(data[1]),'z':str(data[2])}) #AddRecord requires strings as arguements str()
            progress+=3
            time+=dt
            droid.dialogSetCurrentProgress(progress)
        droid.dialogCreateAlert('Done', 'Go check your data on Docs')
        droid.dialogSetPositiveButtonText("OK") #Yes option box
        droid.dialogShow()
        droid.dialogGetResponse()

if __name__ == "__main__":
        main()

Google Translate Toolkit for Collaborative Language Learning

I was speaking with my school's Spanish Teacher and she was frustrated at how Google Translate was sometimes incorrect or not aware of nuances. Google Translate works by analyzing documents in different languages to discern the syntax and rules by which these languages play by.

This allows languages to be translated into one another that might not have been before (e.g. Korean to Armenian) but is a constantly evolving process and the primary way Google Translate collects data might prevent it from understanding some slang or dialects that are not as well published.



Recently, I discovered the Google Translate Toolkit which allows for collaboration on a text. Upload or type in a text, and share it like a Google Doc. Collaborators can work to translate the text and even selectively translate with Google and other online resources.

With so much information in English, taking a useful website, Wikipedia page, or tutorial and working with your students to convert it into another language would help make the world a little smaller. Students are already working to translate texts, why not crowdsource time to translate something that would help everyone else. Imagine how your students will benefit from working on an actual document off the web (and the prior discussion of which documents would be most useful) and helping others while better learning their language.


It's not often enough that technology is able to support the learning of languages and cultures, I hope you will find ways to use this free and easy service to create an exciting project while helping others around the world.

Lessons from a Back Injury - My Own Personal Zen Master

Note: 7 years later I wrote an update to this post to expound upon the most important gift I'd gained from my back injury.

About ten years ago, I was injured while serving in the Navy. From that point on I have never ceased to be in very intense pain. This post is not about seeking pity, in fact it's about how after ten years I can talk about how I am grateful for this injury and hopefully how you can learn from it too (without having to be similarly injured).

For the first few years, I tried every possible procedure and treatment one could think of (don't send me any suggestions, I am sure I've tried it) and after a while it was very hard to accept that this would become my  new normal. My back pain had become a part of my identity and I was tired of being the pity case or the person unable to do anything, so I decided to change that.

Nothing I am about to say should be construed as medical advice or "the right way to do it", this is simply my journey and what has worked for me.

Much of what I now know can be summed up in the quote by Thich Nhat Hanh, "Smile, breath deeply, and go slowly." The reason I am writing this to everyone is because I have realized that everyone of us experiences these pains and stressors, I just feel it much more quickly and frequently than you.

Learning to breath was the single most important thing I did. To westerners that sounds silly and I've learned that even many practitioners of Yoga and the like forget to do it and focus on the actions. One could stop everything, simply breathe and be in a perfect place. I am going to suggest that if you are in pain or stressed, it is likely because you are improperly breathing. If you have an injury or condition that is causing your pain, the suffering is made worse by your improper breathing. I catch myself often making shallow breaths, just barely enough to stay alive throughout my day and that is so silly for a resource that is 100% free. Deep mindful breaths are so incredible and yet I am still working to do it all day.

I stopped growing in 8th grade, that leaves my height around 5' 4". When I first received my injury and the military put me on bed rest for 6 months, I gained a lot of weight. This weakened my abdominal muscles and added dead weight to my stomach. This increased my level of pain and I came to find out how important the abs are. If they are weak, it is impossible to support your body which leads to pulling and straining of your upper back and neck. With so many of us struggling with weight and sitting at a desk, this is a very real issue. Someone once told me, if your abs are flabby, your body isn't happy.

Long ago in my search for anything that would help me, I became very interested in nutrition. As background, I LOVE sweets. Cakes, cookies, juice, soda you name it I love it. I read somewhere that if you stop anything for 30 days you can do it for a lifetime. I decided to cut out soda and not only did I lose weight, but I also felt better in general. For those of you interested in following in my footsteps, Dr. Oz has a great a step-by-step plan. Its funny how far we will go to lose weight, we will work out, take  pills, but we won't change our eating habits. I am unable to work out except gentle Pilates and Yoga but changing my eating habits has allowed me to maintain a healthy body weight and tone.

A lesson I have only recently learned is due to my son and my new job. My son and I love to play. Wrestling and having fun takes me back to when I was a kid and it is wonderful that I get to give that to my son. I promised myself if I ever had kids, I would not allow my back to take anything away from their childhood. So even though the pain abounds I happily give my son a piggyback ride or take him to the park. Its from taking these walks that I have learned so much. When I am stuck on a problem or stressed out, nothing helps me more than to take a walk, be mindful, and play.

As a teacher, I never took time to leave my classroom. I would go to the lounge and talk with people but I never walked. Now in my current job, I walk every so often both to stretch but also to think. It is impossible to be creative and mindful for 8 hours in a chair. I don't know how people do it. Perhaps they think it would distract them or ruin their productivity, but I can assure you when I come back from my 10 minute walk I am energized and ready to work at my best.

Taking a walk in today's world may seem like a waste of time or that we have better things to do, but I can assure you it will become the best part of your day. Do it with family or friends as well as by yourself and you will find you can't do without it.

Finally, I should mention that if I didn't have my back injury I would have never met my wife nor all of the amazing people I have met over the last 10 years. Right before I injured my back, I was selected for an officer program in the Navy and I was planning on staying on as a career. Well that is when my other favorite quote became meaningful to me, "If you want to make God laugh, tell him what your plans are for tomorrow." While I am sure the life I would have lived would have been great, I wouldn't trade anything for the love and joy that I feel everyday. The students and people I have worked with to create some incredible things are worth anything I experience in regards to pain.

So there you go. Ten years and I am able to work at a great job, raise a wonderful family, and while the pain is there I have learned to let it be a reminder to be mindful and for that I am grateful to it. I do not offer this as a roadmap or instruction manual but as a call for whatever you are suffering from, don't seek to end it. Learn from it and find peace within it. That may sound very wishy washy to those of you in very painful situations but one day, you will find peace as long as you take care of yourself and are mindful.

If you do leave a comment, thanks but please do not wish me pity (I need none) nor tell me about your amazing friend who saw an infomercial for this inverted chair that can cure me.... as I said I am able to maintain a happy life in spite of the pain and after 10 years of seeking every possible treatment, I have found that there is not a whole lot that can be done externally, I must work to be mindful and I would encourage you to cultivate it as well.

Subscribe to BrokenAirplane!

The Four Pillars of Math Education

I have had the pleasure of finding excellent books and articles this summer, it seems like change is in the air. If you want to know whether I am really enjoying reading something, look and see if I have a piece of paper out (or my phone), writing down all my thoughts. My wife tells me to read something to take my mind off things every once in a while, but if it isn't thought provoking then what's the point?

I believe I came across this article first in an EDU-SIG Python mailing but I cannot find the original post. This group participates in discussions regarding education and computing (specifically with the Python Programming Language). It is an excellent convergence of brilliant minds and I highly recommend it anyone with an interest in the subject.

The article is titled The Four Pillars Upon Which The Failure of Math Education Rests and in it Matt Brenner writes with the same passion and conviction as the writer of Lockhart's Lament (original article is a free PDF) so famously wrote. While there is no difference in the passion nor the topic of discussion, Four Pillars involves not didactic rhetoric but data and research. The article is longer, but it provides concrete steps math educators (and other content subjects as well) can take to make effective change in the classroom and is well worth the time.

If I may spoil the surprise a little bit to review the article, he shows an avalanche of data to support the claim that high stakes standardized testing based education (as it currently exists) is not working (no surprise to anyone reading this blog I'm sure). The claims of growth and success within districts or states are found to be the result of playing with the data or setting goals so low that it would be impossible not to meet them.

Additionally, we have feedback loops that makes it difficult to create reform. One example cited is the ever increasing size of the textbooks in order to be perceived as the best resource for schools. This results in a curriculum that becomes less and less based in understanding but in "skimming" information and "covering" facts. This arms race cannot cease as no textbook publisher seems interested in reducing the content to cover more in depth as it would potentially be perceived as less/lower quality.

In another cycle we must break out of, we are now in a society where the technology of our lives is far different than the ones our parents did. The ways and amount we can learn is staggering but we still teach and act as if the technological breakthroughs never happened. While we could continue to think that as long as we do it as well as our teachers did for us, things will carry on as they have. However, our society is different in many ways and calls for new learning in method and matter.

The article/book continues to point out the flaws in our educational system, but points more specifically to the flaws in math education. But far from a doom and gloom prophet, he provides excellent suggestions for what can be done tomorrow. Yes, while there are big picture issues to overcome there are still things we can do in our classrooms to break from the pedagogy of the past.

If Lockhart's Lament stirred you but left you wanting more, check out The Four Pillars.