Sunday, October 7, 2012

[Tutorial] Bash Script for Arduino Uploader

Following the recent tutorial I wrote about flashing an Arduino hex file remotely using a Raspberry Pi, I wrote a bash script to automate the process.  To use this function, just copy the highlighted code to your .bash_profile or .bashrc file in your home directory.  With this function, you can just type arduinoupload path/to/my/file.hex in the command line and it will take care of the rest (assuming that you are trying to flash an Arduino Duemilanove using the "pi" user on the Raspberry Pi at IP 192.168.2.16 AND that you have already setup an SSH public key between the two).  If you don't set up the SSH keys, you will be prompted to enter your password.  You can tweak the function to adjust it to your setup, or you can rewrite it to make it more flexible.  I chose to hardcode these values because my setup (IP, user, Arduino model) never changes.

This is just an interesting little bash script that somebody may be able to make use of.  If you want any explanations regarding the script, you can either ask me in the comments or use Google (I'm new to bash so it probably will be more helpful that I will be).

Thanks for stopping by!

Chris Konstad

No comments:

Post a Comment