Bored of the arduino interface ? We are too.
We will explain here how you can compile your sketch directly from a terminal, upload them to your arduino and open a serial monitor by listening to the serial port.
To compile your sketches in the commande line, you’ll use make, as you’re probably used to. To enable this feature you must install the arduino-mk package. On Ubuntu you can do a simple:
sudo apt-get install arduino-mk
You will then need to create a Makefile in the folder containing your sketchbook. This is what it should contain:
BOARD_TAG = # Here goes your board type, e.g. : uno ARDUINO_PORT = /dev/ttyACM0 # Change to your own tty interface ARDUINO_LIBS = # The libs needed by your sketchbook, examples are : Wire Wire/utility Ethernet... include /usr/share/arduino/Arduino.mk # This is where arduino-mk installed
For arduino 1.0 and above, you’ll want to give the .ino extension to your source file. You can now use the command
make to compile your sketch, and
make upload to send it to the board.
If your program is giving you feedback or waiting for instructions from the serial line, you might want to open a serial monitor. But we’re trying to get rid of the arduino interface, ain’t we ? So we’ll rather open a serial listener in the terminal. We’ve wrote a little python script that will correctly display the communication line with your arduino.
#! /usr/bin/python # Serial Reader for ARDUINO # usefull when tail -f /dev/ttyXXXX doesn't work # # Change ttyACM0 for your own tty interface import serial import time # The second argument is the baudrate, change according to the baudrate you gave to your Serial.begin command ser = serial.Serial("/dev/ttyACM0", 115200) # To avoid communication failure due to bad timings ser.setDTR(True); time.sleep(1); ser.setDTR(False) while True: print ser.readline()
Comment by Mike (blog.mired.org) :
Why do people ditching the Arduino IDE keep missing the cu command? A nice, powerful serial comm program that’s been a standard part of Unix since before Linus ever heard of Linux. If you’re on Linux, there’s a version available for that as well. Just do “cu -p /dev/ttyACM0 -s 115200″ and viola, you’re talking to your Arduino. No coding, no funky terminal emulator configuration, just a connection.