The Freetronics LeoStick (product page) is a handy break-out board for the ATmega32U4 microcontroller, and was given as a special surprise for attendees of linux.conf.au, the annual Australian Linux conference, as a thankyou from Freetronics and Linux Australia. The board is similar to other 32U4 breakout boards with the Leonardo bootloader but with a nice USB stick format and on-board parts, and is based loosely on the pinout and connections of the upcoming Arduino Leonardo reference design for compatibility with the Arduino IDE. Before you plug in your LeoStick for the first time please read this section of the forum for any updates on installation and use.

Some more cool stuff has been added to make it fun and versatile on top of being a great little USB stick sized board: It has a user-controllable RGB LED on the board and also an on-board Piezo/sound generator so you can make your board light up and play sounds without any extra hardware at all. We've worked on a few unreleased designs for USB-stick format Arduino-compatible boards for over a year now, so it's exciting to release this latest board!

The LeoStick uses the ATmega32u4 microcontroller and works with most Arduino software, and is even electrically (but not physically) compatible with typical expansion shields. It provides the same expansion headers as the Leonardo and other models such as the Arduino Uno, but in a different physical layout to match the super-small board.

The LeoStick is powered automatically by the USB connection from a host computer, or you can connect an external 5Vdc regulated power supply to run it independently.


  • Keep it in your pocket! Plugs straight into any USB port.
  • On-board RGB LEDs, one for full programmable RGB use and the other for Power, USB RX and TX status.
  • On-board piezo sound generator.
  • Supplied with low profile header socket strips to easily plug in any modules or extra hardware.
  • AVR core ATmega32U4 microcontroller with 32K of Flash, 1K of EEPROM and 2.5K of RAM, running at 16MHz.
  • Regular AVR 6 pin ISP connector for reflashing the bootloader, board or direct application programming.
  • On-board reset button.
  • 0.1" pitch pin spacing, fits into solderless breadboard or veroboard pads.



Using the LeoStick with the Arduino IDE

The LeoStick can be programmed using the Arduino IDE, which is the software development environment designed to work with Arduino-compatible boards. Before you can load your programs onto the LeoStick you need to install the Arduino IDE and configure it to recognise your LeoStick board.

There are two different methods for setting up the Arduino IDE to work with the LeoStick. We'll explain both of them and you can choose which method to use.

Method 1: Enable The Built-In "Arduino Leonardo" Board Profile

The simplest option is to enable the built-in Arduino Leonardo board profile included in v1.0 of the Arduino IDE. That profile works just fine with the LeoStick but it's disabled by default because the official "Leonardo" board hasn't been released yet. The possible problem with this option is that even though the Leonardo board profile included in Arduino IDE v1.0 works well with the LeoStick, it may be changed in future releases and no longer be compatible. If that's the case you can later use Option 2 as described below.

Follow these steps to install the IDE and enable the Leonardo board profile for use with the LeoStick.

1. Install the Arduino IDE

Download the latest Arduino IDE (version 1.0 or higher) for your operating system from www.arduino.cc/en/Main/Software and install it to suit. You'll also find more step-by-step guides for installation here: www.arduino.cc/en/Guide/HomePage. Make a note of the location selected by the IDE for the "sketchbook" directory: you can check by launching the IDE and looking in File > Preferences.

Windows users please note: The USB driver for the LeoStick must be downloaded and used for first-time installation of the LeoStick's USB port. See www.freetronics.com/leostick-usb-driver. Linux and MacOS do not require any drivers.

2. Enable the Leonardo Board Profile

Go to the location where you installed the Arduino IDE. Using a plain-text editor (not a word processor!) open the directory "install-location/hardware/arduino/boards.txt" and go to line 147. You will see a block of lines that have been commented out using "#" characters at the start of each line going down to line 161. Remove the leading "#" characters and save the file. The result should look like this:
leonardo.name=Arduino Leonardo
leonardo.upload.protocol=arduino
leonardo.upload.maximum_size=28672
leonardo.upload.speed=1200
leonardo.bootloader.low_fuses=0xde
leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
leonardo.bootloader.path=diskloader
leonardo.bootloader.file=DiskLoader-Leonardo.hex
leonardo.bootloader.unlock_bits=0x3F
leonardo.bootloader.lock_bits=0x2F
leonardo.build.mcu=atmega32u4
leonardo.build.f_cpu=16000000L
leonardo.build.core=arduino
leonardo.build.variant=leonardo

 

3. Initial Port Setup

Now we're ready to do the initial board and port setup. You won't need to do this again unless the serial port identifier changes such as when using a different USB port on your computer.

Launch the Arduino IDE, and select Tools > Board > Arduino Leonardo.

Before connecting your LeoStick to the USB port, have a look at the list of ports in Tools > Serial Port. That's where your LeoStick is going to appear when you plug it in. Note: this menu option may be disabled until a new serial port appears, so just move on to the next step.

Connect your LeoStick to the computer USB port. After a short while if you look at Tools > Serial Port again you'll see a new port appear: that's the LeoStick ready to be used. Select that port now with Tools > Serial Port so there is a tick mark next to it.

You're ready to go! The Arduino IDE now knows about your board and has a connection to it. Our LeoStick boards ship with a test program preloaded so you should immediately see the blue power LED illuminate, the piezo speaker will beep, and the RGB LED will begin flashing different colours.

Method 2: Install The "Freetronics LeoStick" Board Profile

This method is slightly more complicated to set up initially, but has the advantage that it should continue to work with future releases of the Arduino IDE. It's possible that the Arduino Leonardo profile may change in future, so having a specific profile for the LeoStick is an insurance policy against that.

Follow these steps to install the IDE and install a special LeoStick board profile.

 

1. Install the Arduino 1.0 IDE

Download the latest Arduino IDE (version 1.0 or higher) for your operating system from www.arduino.cc/en/Main/Software and install it to suit. You'll also find more step-by-step guides for installation here: www.arduino.cc/en/Guide/HomePage. Make a note of the location selected by the IDE for the "sketchbook" directory: you can check by launching the IDE and looking in File > Preferences.

Windows users please note: The USB driver for the LeoStick must be downloaded and used for first-time installation of the LeoStick's USB port. See www.freetronics.com/leostick-usb-driver. Linux and MacOS do not require any drivers.

2. Determine Sketchbook Directory Location

Launch the Arduino IDE and determine the location of the "sketchbook" directory. You can find it by selecting File > Preferences. Make of note of the location, and quit the IDE when you're done.

3. Create Hardware Directory

Inside the sketchbook directory you just located, create a new directory called "hardware".

4. Download Board Profile

Download the LeoStick board profile from here. Once it has been saved to your local computer, uncompress it using a utility such as WinZip. Inside the extracted directory you will find a directory called "LeoStick".

5. Install Board Profile

Move the "LeoStick" directory into the "hardware" directory you created a moment ago. You should end up with a structure like "sketchbook/hardware/LeoStick".

6. Initial Port Setup

Now we're ready to do the initial board and port setup. You won't need to do this again unless the serial port identifier changes such as when using a different USB port on your computer.

Launch the Arduino IDE, and select Tools > Board > Freetronics LeoStick.

Before connecting your LeoStick to the USB port, have a look at the list of ports in Tools > Serial Port. That's where your LeoStick is going to appear when you plug it in. Note: this menu option may be disabled until a new serial port appears, so just move on to the next step.

Connect your LeoStick to the computer USB port. After a short while if you look at Tools > Serial Port again you'll see a new port appear: that's the LeoStick ready to be used. Select that port now with Tools > Serial Port so there is a tick mark next to it.

* If you're using Windows, jump here and back for quick instructions on getting your one-time drivers installed for the board.

You're ready to go! The Arduino IDE now knows about your board and has a connection to it.

Compiling and Uploading Your First Sketch

"Sketch" is the Arduino term for a program. To test uploading a simple sketch to your LeoStick, follow these steps.

Choose File > Examples > Digital > Blink. You'll see the code for Blink open in the IDE.

Select Sketch > Verify/Compile, you've now built (compiled) the program ready to be loaded.

Lastly, to load the program into the LeoStick, select File > Upload to I/O Board. You'll see the combined PWR/TX/RX LED flicker different colours while the upload is being done.

A few seconds later the RX and TX indicators will go off, the board will reset, and the red D13 LED will begin flashing on and off at 1 second intervals. Congratulations! You've now compiled and uploaded your first sketch to the LeoStick. Try experimenting with changing the delay values in the sketch and repeating the process to see the LED blink at different rates.

Using the RGB LED

Most Arduino models include a red LED already connected to digital I/O pin D13, so that you can easily control it from software without needing to add any other parts. The LeoStick instead includes a full RGB LED, with the red element connected to D13. It's therefore compatible out of the box with example sketches that assume there is a red LED connected to D13, but gives you the flexibility of being able to display a full range of colours by blending the red, green, and blue elements. The green element is connected to D9, and the blue element to D10. The pin assignments are printed on the bottom of the LeoStick for easy reference.

Using Piezo Sound Output

The piezoelectric transducer mounted on the bottom of the LeoStick is connected to digital I/O pin D11, which you can use to generate different tones.

Warning: At the moment, do not use the "tone()" function with the Piezo speaker! Remember we said that software support for the Leonardo is still beta-quality? Currently the timer used for pulse-width modulation on D11 causes the board to lock up, and the only way to recover is to upload a new sketch during the first few seconds or so after resetting the board when the bootloader is active.

You can generate different tones on the piezo speaker by using variable delays in a loop, but just for now you can't do it using PWM.

LeoStick Discussion Forum

There is a special section of the Freetronics Forum for discussion of the LeoStick:

    Freetronics LeoStick Forum Section

Resources

Schematic


LeoStick Specifications

Microcontroller
MCU Type
Atmel ATmega32u4
Operating Voltage
5V
MCU Clock Speed
16 MHz
LeoStick
Input Voltage
5V DC via USB port or "5V" header
Digital I/O pins
14 (6 provide PWM output)
Analog Input Pins

6 (analog input pins also support digital I/O,
giving 20 digital I/O total if required)
Analog Resolution
10 bits, 0-1023 at 5V AREF is approx 0.00488V; 4.88mV per step
Current Per I/O Pin
40 mA maximum
Total Current For All I/O Pins
200mA maximum
Current For 3.3V Output
50mA maximum
Memory
Flash Memory
32 KB Flash Memory, of which approximately 2 KB is used by the bootloader
SRAM, EEPROM
2.5 KB SRAM, 1 KB EEPROM
Communications
Serial 1 x hardware USART (D0=RX, D1=TX); SPI (Serial Peripheral Interface); I2C
Other

Integrated USB programming and communication port. Many other one-wire, multi-wire, LCD and expansion devices supported by free code and libraries