Introduction: How to Use Google Sites to Control a Arduino!

Picture of How to Use Google Sites to Control a Arduino!


CHECK OUT THE LIVE VERSION HERE: https://sites.google.com/site/arduinoexampleswitch/
this is a tutorial that will show you the potential of web based interfaces for your projects, often times we all would like to make stuff for the world to be able to play with but we also often times do not have the time and money to throw at a project to do so, so without further adieu, heres how this works:

step one:
user clicks button in the google apps script that is imbedded in a google site, upon this action the script writes to a text file the desired command, the text file is saved in a google drive account.

step two:
application running on the machine the arduino is attached to downloads the the text file from the google drive, and then sends the contents of the file to the serial port that the arduino is attached to

step three:
the arduino executes the command received over the serial port

Step 1: The Arduino

Picture of The Arduino

So for all of this to work, we first need something to control, for this i have supplied some code that is located in the zip file on this step, its a simple sketch that allows you to turn an led on and off by sending a 1 or a 0 to the arduino via the serial port. it is found in the folder titled "arduino code" when you get the code opened in the arduino environment, you can just upload the code to your arduino, nothin terribly special here

Step 2: The Google Site

Picture of The Google Site

now we must set up the google site and script that will be used to send commands to the arduino. first, if you dont already have a google account, sign up for one, second create a google site to be used to host the script, http://sites.google.com/ is were you begin, now that was the easy part, next we will create the script and embed it into the site, to do so, go to your google drive and click on "Create" then click on "more" and then click on "script". this should bring you to the script editor, then click on the "blank project" then delete all the code that was pre-generated by the editor and then copy in this code:


//this code is part of a tutorial to show the
//potential to interface google apps script with
//the arduino microcontroller
//written by Kyle Brinkerhoff

var serialdoc ="0B7LTCy8EaA7pbXJkSnREYVp4RUk"; //this variable is the unique file id for the file saved in google docs.

function doGet() {   // this function is the setup function that calls the UI into existence
var app = UiApp.createApplication();
app.add(app.loadComponent("remote"));//load the ui named "remote"
      return app;
}
//these functions write to the file that stores the command for the desktop application to download and send to the serial port
function ON(){
DocsList.getFileById(serialdoc).replace("1");// write the command to the file to turn the 13pin on
 
}

function OFF(){

  var comclear=DocsList.getFileById(serialdoc).replace("0");// write the command to the file to turn the 13pin off

}


next save your script.
now you will need to create the user interface to drive this code . to do so, in the editor click on "file" and then click on"build user interface" and create a user interface with two buttons, to do this drag from the left hand side of the screen, two buttons, then on the right hand side of the screen, scroll down till you see the text field for the buttons, change one of them to on and for the other button to off, now select a button and scroll down on the left hand side of the screen till you come to "events" and "on mouse click" click on "add server" and select the appropriate function, then repeat this for the other button. then save the ui as "remote"

now you will need to create a text file in your google drive and get the file ID and insert it over the file id of the old file in the code, you will need this later so make a copy of the file id with notepad and save it

now in the script editor, publish your script as a web app so you can get the embed code for your google site. to do this go to your google site editor and click on "insert" and then click on "apps script gadget" and then paste in your embed url and then configure the script as you please.

Step 3: The Pc Application

Picture of The Pc Application

so this application i wrote for this, feel free to use it for your own purposes, but im not liable for damages caused by misuse.

so to use this simply install it, then insert your google docs unique id and select the correct serial port and then click the "connect" button, this will initialize the serial connection to the arduino, then click the start button, and your good to go! 

Comments

computingineducation (author)2017-06-21

Any idea I can not get this working.

FrancescoC51 (author)2016-05-11

Can anyone help me? I can't find the '' build user interface '' and i'm blocked at this point T_T

studleylee (author)2013-11-10

Great job kyle!!!

thanks

I'm a 49year old embedded HW/SW guy and you guys are now making me feel old :-) I totally like your approach to this and will copy many aspect. I like the idea of using a google site/drive and maybe https://developers.google.com/appengine/ to host my web access.
Thanks and keep up the great work.-Lee

temper (author)2013-02-06

Could you explain where in this article Visual Studio 8 is used and why it is required as a step in the instructable?

kyle brinkerhoff (author)temper2013-02-10

howdy! well the application that acts as a interconnect between the apps script stuff and the arduino was written in visual studio c#, ive included the source code for those who wish to improve, or modify to their needs.

mande01 (author)2013-02-05

Hi, Thanks for this, it's a great idea.
I would like to use this with a raspberry PI, could you explain more about the PC application or suggest how to create a linux version of it, or could you put up the code for the pc application.
Thank you,

kyle brinkerhoff (author)mande012013-02-05

simply put, all it does is it downloads the google doc file with this url:https://docs.google.com/uc?export=download&id=0B7LTCy8EaA7pMS02YjdlNmIzOS01OGRhLTQyYzUtYTkyOS1kMWJkMWNhNzM3Zjk

then it saves the file and opens it again, then reads the contents of the text file and sends the string to the serial port for the arduino

as for linux support, your on your own, ive never dabbled with the silly stuff

About This Instructable

9,745views

42favorites

License:

Bio: hi i enjoy making ludicrisly over the top and complex devices.... Being an ameture engineer, I refuse pick the easy option, but rather the one ... More »
More by kyle brinkerhoff:I built a BS detector samsung charge dock the one seam wallet
Add instructable to: