Makefile based flow for any arduino project

16 views
Skip to first unread message

Dilawar Singh

unread,
Apr 25, 2016, 9:50:50 AM4/25/16
to wncc_iitb
One can definitely use Arduino IDE.

This one is for those who prefer terminal (vim/emacs) or find using arduino editor too limiting. Sample project is hosted at https://github.com/dilawar/arduino_sample_project

With this, building and uploading to arduino is as simple as typing

$ make 
$ make upload  # this will detect your port automatically (except for windows)

Works on Cygwin, Mac and Linux.

What to change?

All source code goes into src folder. Open the makefile and changes the values of LOCAL_INO_SRCS (there should be one or zero .ino file in your project).

Source files have extensions either .cpp or .c. Append them to variable LOCAL_CPP_SRCS. For example, this sample project has the following:

## INO file and other cpp files
LOCAL_INO_SRCS     = $(PROJECT_DIR)/src/eye_blink_main.ino 
LOCAL_CPP_SRCS     = $(PROJECT_DIR)/src/TriggerImaging.cpp \
        $(PROJECT_DIR)/src/Solenoid.cpp \
        $(PROJECT_DIR)/src/PhaseChangeRoutine.cpp \
        $(PROJECT_DIR)/src/main.cpp \
        $(PROJECT_DIR)/src/LocalLibrary.cpp \
        $(PROJECT_DIR)/src/LCDRelated.cpp \
        $(PROJECT_DIR)/src/Initialize.cpp \
        $(PROJECT_DIR)/src/DetectBlinks.cpp \
        $(PROJECT_DIR)/src/Globals.cpp \
        $(PROJECT_DIR)/src/ChangePhase.cpp 

You don't have to change anything else. I've tested is on Mac and Linux.

Of-course you need to install arduino. Even if you don't have a board to connect to, you can still build this project to see if everything is fine. You can use `miniterm.py` (package python-pyserial) to communicate with your serial port.

Open a ticket on repository if something is not working.

Best,
    Dilawar
Reply all
Reply to author
Forward
0 new messages