metalx1000

Setup Arduino project for Shell Compiling

Jun 19th, 2015
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.92 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2020  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation, either version 3 of the License, or
  9. #(at your option) any later version.
  10.  
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #GNU General Public License for more details.
  15.  
  16. #You should have received a copy of the GNU General Public License
  17. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. ######################################################################
  19.  
  20. mk="/usr/share/arduino/Arduino.mk"
  21. sketchdir="$HOME/sketchbook"
  22. [[ ! -f "$mk" ]] && sudo apt-get install arduino-mk
  23.  
  24. mkdir -p "$sketchdir" &&
  25. cd "$sketchdir" &&
  26. ln -s "$mk" 2> /dev/null
  27. mkdir -p blink &&
  28. cd blink &&
  29.  
  30. cat << EOF > blink.ino
  31. // Blink
  32.  
  33. void setup(void) {
  34.   pinMode(13, OUTPUT);
  35. }
  36.  
  37. void loop() {
  38.   digitalWrite(13, LOW);
  39.   delay(1000);
  40.   digitalWrite(13, HIGH);
  41.   delay(1000);
  42. }
  43. EOF
  44.  
  45. tag="atmega328    Arduino Duemilanove or Nano w/ ATmega328    
  46. atmega168    Arduino NG or older w/ ATmega168      
  47. atmega8      Arduino NG or older w/ ATmega8      
  48. bt           Arduino BT w/ ATmega168          
  49. bt328        Arduino BT w/ ATmega328          
  50. diecimila    Arduino Diecimila, Duemilanove, or Nano w/ ATmega168
  51. fio          Arduino Fio            
  52. lilypad      LilyPad Arduino w/ ATmega168      
  53. lilypad328   LilyPad Arduino w/ ATmega328      
  54. mega         Arduino Mega (ATmega1280)          
  55. mega2560     Arduino Mega 2560            
  56. mini         Arduino Mini          
  57. pro          Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168  
  58. pro328       Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328  
  59. pro5v        Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168    
  60. pro5v328     Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328    
  61. uno          Arduino Uno"
  62.  
  63. tag="$(echo "$tag" |fzf --prompt "Select Board"|awk '{print $1}')"
  64.  
  65. #Set Tag
  66. #echo "What is your TAG? (example: atmega328)"
  67. #read tag
  68. [[ "$tag" = "" ]] && tag="atmega328"
  69. echo "Tag set to $tag"
  70.  
  71. #Set Port
  72. port="$(ls /dev/ttyUSB*|fzf --prompt "What is your Serial Port (example: ttyUSB0)")"
  73. [[ "$port" = "" ]] && port="ttyUSB0"
  74. echo "Serial Port set to $port"
  75.  
  76. cat << EOM > Makefile
  77. BOARD_TAG = $tag
  78. ARDUINO_PORT = $port
  79. ARDUINO_LIBS =
  80. ARDUINO_DIR = /usr/share/arduino
  81. include ../Arduino.mk
  82. EOM
  83.  
  84. echo "Setup complete!!!"
  85. echo "'make' to make"
  86. echo "'make upload' to make and upload to board"
  87. echo "Project is in $HOME/sketchbook"
Add Comment
Please, Sign In to add comment