Skip to content

Instantly share code, notes, and snippets.

@JamesTheAwesomeDude
Last active April 7, 2020 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesTheAwesomeDude/b779b4a8072b537d71876f87adf27e70 to your computer and use it in GitHub Desktop.
Save JamesTheAwesomeDude/b779b4a8072b537d71876f87adf27e70 to your computer and use it in GitHub Desktop.
necessary/skeletal Arduino "sketch" files
# /etc/udev/rules.d/99-arduino.rules
SUBSYSTEM=="tty", ATTRS{manufacturer}=="*Arduino*", GROUP="james"

These three files (well, plus arduino-mk, which I've tested working perfectly out-of-the-box on both Ubuntu 18.04 and Debian 9,) are all you need to get started programming an Arduino in your favorite IDE, on your current Linux setup.

First-time setup (Only need to do this once)

  • Drop 99-Arduino.rules in /etc/udev/rules.d/ (don't forget to edit your usergroup into it!)
  • Run #udevadm control --reload-rules
  • Run #apt install arduino-mk

To start a new sketch

  • Copy this Makefile and main.ino into a folder
  • Write your program into main.ino
  • Run make clean upload minicom to take it for a spin!
  • You might have to edit the Makefile to set BOARD_TAG and MCU if it's not working right
  • Don't forget to use version control!
    • (*Especially when the project is just getting started. You will break your code and be unable to fix it at some point.)
# /etc/profile.d/arduino-sketchbook.sh
# OPTIONAL file to put the location for the official IDE
# somewhere more-reasonable
# Alternatively: just append this to your ~/.profile
#if [ -d "${HOME}/Documents/Programming/Arduino" ] ; then
ARDUINO_SKETCHBOOK="${HOME}/Documents/Programming/Arduino"
#fi
void setup(){
Serial.begin(9600);
// pinMode(LED_BUILTIN, OUTPUT);
}
/*void serialEvent(){
digitalWrite(LED_BUILTIN,Serial.read()&0b01000000);
}*/
void loop(){
;
}
ARDUINO_DIR = /usr/share/arduino
#BOARD_TAG = uno
#MCU = atmega328p
#DEVICE_PATH = ttyACM0
include $(ARDUINO_DIR)/Arduino.mk
.phony minicom:
minicom -b $(MONITOR_BAUDRATE) -D $(DEVICE_PATH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment