using Emacs to develop

Processing & Arduino

Part 2 Arduino

by Shelandy Ting

powered by Emacs + reveal.js + github

More innstruction on

follow the instruction on

https://github.com/sudar/Arduino-Makefile#usage

https://www.emacswiki.org/emacs/ArduinoSupport

https://wiki.archlinux.org/index.php/arduino

Windows and OSX have a similar prcoess of installation, most on specify some files

Software Requrement

  • Arduino IDE
  • python-serial
  • Arduino-Makefile
  • avrdude

Hardware

it supports several different board, including Uno, Mega,....

download arduino IDE

RPM or https://www.arduino.cc/en/Main/Software

Install pyserial

RPM,...

pip install pyserial

# or if you prefer easy_install

easy_install -U pyserial

Install Arduino-Makefile

  • goto https://github.com/sudar/Arduino-Makefile
  • download the Aduino-Makefile-master. zip file
  • cp Aduino-Makefile-master.zip /usr/local
  • cd /usr/local
  • unzip Arduino-Makefile-master.zip
  • mv Arduino-Makefile-master Arduino-Makefile

modify system-wide environment setting

change three lines of in your Aduino.mk (e.g., /usr/local/Arduino-Makefile/Arduino.mk) around line 50~60, add the following


		AVR_TOOLS_DIR = /usr
		ARDUINO_DIR   = /usr/local/arduino-1.6.12
		ARDMK_DIR     = /usr/local/Arduino-Makefile
	    

modify personal environment configuration

  • Linux
  • add the follwing to ~/.bashrc or .bash_profile
    
    		export ARDUINO_DIR=/usr/local/arduino-1.6.12
    		export ARDMK_DIR=/usr/local/Arduino-Makefile
    		export AVR_TOOLS_DIR=/usr/include
    	    
  • Windows

    ARDUINO_DIR=../../../../../Program\ Files\ \(x86\)/Arduino

  • OSX

Project-wide setting

    configuration of ech project
    • Arduino usually use the following file structure
    • ./myProjectName
    • ./myProjectName/myProjectName.ino
  • make a file called ./myProjectName/Makefile
  • using emacs then configure / adjust the project's Makefile as the following:

		BOARD_TAG = uno #= mega2560 if your board is Mega
		MONITOR_PORT = /dev/ttyACM0 # you shoukld able to find this under your device manager
		ARDUINO_LIBS = Wire SoftwareSerial  # put whatever libraries you need over there
		include /usr/local/Arduino-Makefile/Arduino.mk
		AVR_TOOLS_DIR= /usr
		AVRDUDE      = /usr/bin/avrdude
		AVRDUDE_CONF = /etc/avrdude/avrdude.conf
	    

firmware uploader for Arduino

  • in Linux use avrdude http://download.savannah.gnu.org/releases/avrdude/
  • in Windows,
    • use winavr https://sourceforge.net/projects/winavr/
    • https://sourceforge.net/projects/winavr/files/WinAVR/20100110

Running Package Management

install arduni-mode

		(add-to-list 'auto-mode-alist '("\\.ino\\" . arduino-mode))
		(autoload 'arduino-mode "arduino-mode" "Arduino editing mode." t)
	    
Need to log out the system after changing the setting

Compile and run

  1. load your XXX.ino file buffer
  2. M-x compile
  3. the default argument is "make -k", just hit the enter
  4. if satified the compilation, use "M-x compile" and "make -k upload"
fin
emacs.d/.init.el setting for Processing mode

	      
	  

Table Of Content

need a authoring tool to make up here as the end:

  1. title page
  2. the rest pages here...