The size and appearance of the various Arduino board differs, but they all have things in common:
- A circuit board with various labelled input/output pins.
- A small number of integrated LED lights.
- An USB connector of some kind.
- This might be "micro", "normal", or "blocky".
When programming it, or experimenting generally, all you have to do is connect it to your (Linux) system via the supplied USB cable.
Once connected to your system you should find you have a new device appear, thanks to the wonders of hotplugging. The new device will be called
/dev/ttyACM0
, or similar. The simplest way to find out what the new device is called is to use thelsusb
utility which will show you your connected USB devices.Run
lsusb
, then plug in the board, and finally run it again. In my case before I see this:$ lsusb Bus 006 Device 002: ID 8087:8000 Intel Corp. Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 005 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 004 Device 015: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0 Bus 004 Device 013: ID 062a:4101 Creative LabsAfter insertion I see this:
$ lsusb Bus 006 Device 002: ID 8087:8000 Intel Corp. Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 005 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 004 Device 015: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0 Bus 004 Device 013: ID 062a:4101 Creative Labs Bus 001 Device 008: ID 2a03:0043So I know the USB-device which appeared is the arduino board, which was described by this line:
Bus 001 Device 008: ID 2a03:0043By default the permissions are configured such that I cannot read/write to the device, so we'll fix that, and create a handy symlink for ease of future identification. We'll do this by creating a local
udev
rule in the file/etc/udev/rules.d/99-arduino.rules
- create that file, and give it the following contents:SUBSYSTEM=="tty", GROUP="plugdev", MODE="0660" SUBSYSTEMS=="usb", ATTRS{idProduct}=="0043", ATTRS{idVendor}=="2a03", SYMLINK+="arduino"NOTE: The numbers in bold come from the output of
lsusb
which we saw earlier. You'll want to use the numbers you see.Now that the new
udev
rule is in place we need to reload the service, unplug the device, and plug it in again. That will allow the new rule to be recognized and applied. Reloading the rules can be achieved via:# /etc/init.d/udev reloadOnce that is complete we'll see we have the symlink, and better permissions.
$ ls -l /dev/arduino /dev/ttyACM1 lrwxrwxrwx 1 root root 7 Jan 5 08:15 /dev/arduino -> ttyACM1 crw-rw---- 1 root plugdev 166, 1 Jan 5 08:15 /dev/ttyACM1NOTE: My user is a member of the
plugdev
group, so I can now read/write to the device.
To write your code, and upload it to your board over the USB cable, you'll need to install the Arduino IDE, which is currently version 1.8.0.
You can find the project here:
The project is written in Java, so you'll need to have a suitable runtime installed.
The current stable release of Debian GNU/Linux includes
openjdk-7-jre
, which is sadly too old to run the project. To run the IDE you'll need to install the openjdk-8-jre package, via the backports repository.
Once installed you can launch the IDE, and you'll need to make two configuration changes:
- Specify the type of board you have connected.
- Specify the appropriate device-name.
To specify the board you have click on the
Tools
menu, and select the appropriate item beneath theBoard
sub-menu. In my case I selected "Arduino/Genuino UNO".Specifying the device is similar, choose the
Tools | Port
menu, and select the device we identified in the "Identification & Permission Setup" step.You should now be able to proceed with the exciting world of Arduino development!
Open your IDE, if not already opened, and load the supplied
Blink
example. This is done via the Menu:
- File
- Examples
- 01.Basics
- Blink
Once loaded you can click the buttons on the toolbar - hover your mouse over them from left to right and you'll see "Verify" and "Upload".
Click "Verify", which will compile your program, and then "Upload", which will transfer the compiled code to your board.
All being well you should now see a flashing/blinking light!