MT-DB-U2
Manual
D2, D3, etc. These are Arduino digital pins, not to be confused with port D pins. MattairTech boards
are printed with both port pin names as well as sequential numbers indicating Arduino digital/analog
pins (0 means D0 or A0, 10 means D10 or A10, etc).
Using Libraries
There are several libraries included with Arduino. Some of these needed simple changes to
work with MattairTech boards. If a library was ported, it is included in the MattairTech download and
installed in the Arduino user directory with "_MattairTech_Port" appended to the name of the original
directory name. This can be seen in the Arduino IDE in File>Sketchbook>libraries and File
>Examples. If you see the Files>Examples version of a particular library then you must use it instead
of the original library which will still be shown lower on the menu. If there is no Files>Examples
version, then you can use the original, which did not require porting. If there is a library you would like
to use that is not included with Arduino, email support and I should be able to quickly support it. Often,
only pin mappings need to be changed. The I2cMaster library contains a software I2C library that can
be used with the MTDBU1 and MTDBU2, which do not contain I2C hardware.
USB Serial interface
The LUFA directory contains a reorganized subset of the LUFA USB library by Dean Camera
(fourwalledcubicle.com). It implements a CDC class device, which appears as a COM port on the host
computer. A terminal emulator or the Arduino serial monitor can be used to communicate with the board.
Use this interface the same way you would on a standard Arduino (ie: Serial.println()). The interface is
nearly the same as the one in HardwareSerial.cpp. For example:
void setup() {
Serial.begin(9600); // The default settings for USB options are used (all enabled)
pinMode(2, INPUT);
}
void loop() {
int sensorValue = digitalRead(2);
Serial.println(sensorValue, DEC);
//Serial.flush();
// needed if autoflush is not used
delay(1000);
}
Serial.begin() sets up the USB serial interface with a single 32bit argument. This value is setup by ORing
three USB options together along with the optional baud rate. This works because the three options are
stored in the upper bits of the 32bit value. The baud rate is ignored because the fastest speed supported is
always used (2Mbps for the AT90USB162 and ATmega32U2, 8Mbps for the ATmega32U4). For example:
Serial.begin(9600 | USB_LED_ENABLED | USB_WAITFORCONNECT_DISABLED | USB_AUTOFLUSH_ENABLED);
Note that Serial.begin() is no longer needed to support the HID keyboard or mouse. Also note that
USB_WAITFORCONNECT_DISABLED is now the default option (it was enabled prior to 1.0.5).
USB_LED_ENABLED, USB_LED_DISABLED
If USB_LED_ENABLED is set, then the LED will display the state of the USB connection (on
October 29, 2015
15