Monday, March 31, 2014

Sending and Receiving Data from an Arduino Through a Webpage

I thought it would be kind of cool to be able to control an Arduino remotely so I hacked up a bunch of code that allows me to do this. The website can control multiple Arduino's at one time and recognizes them by their unique IDs that they send.

Basically, what you need is:

A computer running Linux
A webserver, Apache is nice with ability to run Javascript and Perl
Perl
An Arduino

How it works is like this:
1. Arduino sends data to the Serial port that is polled by computer_interface.pl and written to a file that is plotted using gnuplot to display on the webpage
3. Webpage uses web_interface.cgi to write data to a file that is read by computer_interface.pl and sent to Arudino
2. Arduino is polling Serial port to receive data and uses the data to modify variables that can change how the Arduino operates.


What this code was written for was having an Arduino controller multiple pieces of equipment in a Scientific lab but it can be ported to use for many other things.

Here is the Arduino Code: http://pastebin.com/f8eBJc7R
Here is the computer_interface.pl: http://pastebin.com/yGNMCH54
Here is the webinterface.cgi: http://pastebin.com/qpUZ5n9A
Here is the gnoplot formatting file should be in the same directory as computer_interface.pl: http://pastebin.com/1BWNaAc4
HTML file: http://pastebin.com/e2Fpkrfi
HTML CSS: http://pastebin.com/1YUnWS0Q
HTML Javascript: http://pastebin.com/kNvEVa0d

1. Install gnuplot: apt-get install gnuplot or yum install gnuplot
2. Put the HTML files in /var/www/html
3. Setup Perl execution on your webserver  (http://stackoverflow.com/questions/560749/how-do-i-configure-apache2-to-run-perl-cgi-scripts)
4. Make sure you Arduino has code loaded and is plugged in.
5. Run computer_interface.pl in background and make sure the gnuplot file is in the same directory
6. Use!

The webpage refreshes every 30 seconds you can change this in example.html.

The Javascript is just for giving the webpage a tabbed format to run multiple devices. This can easily be removed and changed so that you don't need the CSS or Javascript files.


Sunday, March 30, 2014

SXSW

This post is about a month old but I have been so busy I am just finishing it up.

So for some reason I was fortunate enough to be invited to South by Southwest(SXSW) from the wonderful Karen Ingram and Shawn O'Keefe. At first I didn't know if I would go. Plane tickets were kind of expensive and I am currently in what will probably be the most busiest time of my year (Conferences, Science, Talks, &c.). Also, I am not a spontaneous person and don't like random people. I had never met Karen or Shawn in person and didn't know anyone in person who would be going to SXSW. I can be introverted at times. Well considering I spend most of my non-sleeping life in lab I guess I would be considered significantly introverted, yeah, I mean I just don't usually like people, at least when I am sober. Anyways.... I decided to go because I felt like the opportunity was so good I could not pass it up and because I only had a few days to spare even if it didn't turn out well I wouldn't lose much besides money.

It was a great time. I met Dan Grushkin which was pretty sweet and we achieved the high score on Marvel vs Capcom at a bar and became pretty drunk in the process. Austin basically turns into New Orleans and 4th st. into Bourbon st. I am pretty excited to go again next year and I hope to have some cool Science.Technology to show-off and impress people. Well at least impress myself.

I went to see the movie The Immortalists at SXSW because Jason Sussberg came to the Biohacker meetup and convinced me to go. You should check out the link and trailer and if ever have the chance to see it you should. I really love documentaries and wish people would make more of them. It is just so cool to experience someone else's life that is different from my own or learn about something new. Seriously, I wish I could watch a documentary on everyone I know. I guess that is kind of creepy?

Anyways, there were so many interesting and cool people that I met there. I hope I actually can spend time with them in the future.

I am learning to go a little bit outside my comfort zone more and attempt to experience new things even though I would rather just sit in my apartment and build stuff. Also, I am beginning to see that I don't hate people as much as I say I do. Hah, I think I just don't enjoy people who are boring and.or stuck-up. 



Sunday, March 2, 2014

Passion

I love Science.
Some people do Science and some people enjoy Science but I love Science. I _LOVE_ it.

I am not the best Scientist. I have whacky ideas and spend lots of my time trying to do crazy stuff when I could be actually accomplishing something. It sucks. I wish I was better. I really do. Because. Science is my heart. It is my soul. It is my Passion.

Maybe you are Passionate about Science. Well let's show it.

Watch this video:
http://vimeo.com/18166037

Maybe you are not a football fan. But I am sure you can see the Passion of these footballers. Why is Science different? Why can't we show our Passion and be so Passionate about our work that we cry, scream, hate, love?

Does going to Scientific talks inspire you? Or does it put you to sleep? They usually always put me to sleep. Science is so much a job now. Which is cool. It is cool. Everyone who does Science can't be passionate about it. Do people even have Science heroes anymore though?

Oh you love Neil deGrasse Tyson or Bill Nye, great people who don't even do Science anymore. Bill Nye is not even a Scientist. These people are not the worst, they do attempt to inspire people to do Science. But ya' know what is more inspiring? Someone who is actually in the game, sweating the blood and tears. Toiling to make something. Is that you? Why do you hide it? Are you afraid that showing emotion and Passion might ostracize you in the Scientific world?

Ya' know what I don't want? A science or nature paper. Ya' know what I do want? To maybe hopefully possibly do something that is so intricate and beautiful and someone else sees that and is inspired by it.

I will never be as intelligent as some of the people I know and have worked with. I probably will never rock the Scientific world. But I will always try hard and I will always keep going because Science is too amazing and beautiful to ever give up on.

As ODB said "Science[Wu Tang] is for the children."