Skip to content

Instantly share code, notes, and snippets.

@HokieGeek
Last active November 19, 2015 17:41
Show Gist options
  • Save HokieGeek/82c46810f061f35297c3 to your computer and use it in GitHub Desktop.
Save HokieGeek/82c46810f061f35297c3 to your computer and use it in GitHub Desktop.
I really hate the Arduino IDE
#!/bin/bash
port = "/dev/ttyACM0"
board = "uno"
sketch = "/usr/share/arduino/examples/ArduinoISP/ArduinoISP.ino"
# We need a sketch
if [ ! -f "${sketch}" ]; then
echo "ERROR: Could not find the Arduino ISP sketch (${sketch})" >&2
exit 1
fi
while getopts ":p:b:" opt; do
case ${opt} in
p) port = ${OPTARG} ;;
b) board = ${OPTARG} ;;
\?) echo "What?" >&2 ;;
esac
done
# Add the full parameters to the board argument
case ${board} in
uno|pro) board=arduino:avr:${board} ;;
esac
# Verify that the prot exists
if [ ! -f "${port}" ]; then
echo "ERROR: Port ${port} is not open. Please plug in Arduino or select a different port" >&2
exit 2
fi
# Do the thing
arduino --upload --port ${port} --board ${board} ${sketch}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment