Skip to content

Carduino 32U4

Introduction

Carduino is the new development board belongs to the Longan Cards Family. As its name implies it is small as ½ of a credit card, thin, and light weight. Carduino is pluggable, which means you can plug it to one of the following boards.

  • Extension board
  • Sensor display board
  • Game board
  • Car board
  • Pi Hap

There is a wide array of cards support with the Carduino. All cards are pluggable and share the same board to communicate with the Carduino. Carduino allow you to quickly build prototypes and develop applications.

At the Carduino’s heart is an ATmega32u4 microprocessor and powered with the Arduino Leonardo bootloader allows you to program it using the Arduino IDE. We have written some exciting Arduino libraries that lets you to quickly develop applications.

Here is a list of things that can be found on the front of the Carduino board.

  • ATmega32u4 microprocessor
  • Type-C USB connector – You will need USB to Type-C cable (https://www.longan-labs.cc/2140001.html)
  • Programmable LED – Connects with digital pin 13
  • Reset button – Re-starts the Arduino sketch
  • Three-way selectable switch – Slide this switch to the D⅞ position to use with the Longan game board.
  • Gold fingers (Edge connector)

Specifications

  • Measures 41mm x 33mm
  • ATmega32u4 @16Mhz clock speed with 3.3V or 5V logic/power (datasheet: http://www.atmel.com/devices/atmega32u4.aspx)
  • 32KB of flash memory which 4KB used by bootloader
  • Programmable LED
  • Preloaded with the Arduino Leonardo bootloader
  • Edge connector (Golden fingers) exposes 30 pins (power, digital, analog, PWM, I2C, SPI, UART)
  • Built-in USB communication
  • Type-C USB connector
  • Reset button
  • Three-way selectable switch to use with game board
  • currently supports game board, car board, sensor display board, extension board, and Pi Hap
  • Two mounting holes

Carduino comes with fully assembled and tested, with a USB interface that lets you quickly use it with the Arduino IDE.

Pins

The edge connector (gold fingers) has total of 30 contacts (each side has 15 contacts).

On the front side of the Carduino, a white arrow is printed near the edge connector indicates the pin #1. You can find some pin numbers printed on the edge connector itself (1, 15, and 29). You can count the pin numbers starting with 1 and count by twos from right to left would be 1, 3, 7, 9, 11, 15, 17, 19, 21, 23, 27, and 29. Notice that all the counts are odd numbers.

On the back side of the Carduino, you also can find some pin numbers printed on the edge connector itself (2, 16, and 30). You can count the pin numbers starting with 2 and count by twos from left to right would be 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 and 30. Notice that all the counts are even numbers.

Table below presents the pin numbers and their functions. The pin functions of Carduino is exactly same with the pin functions of Arduino Leonardo.

Power connections

There are two main ways to power the Carduino.

  • Through the micro-C USB port with 5V
  • Through one of the boards with AAA battery card with 5V

Following pins allow you to power the Carduino with batteries (AAA battery card) through one of the Longan boards.

  • VCC – 5V regulated supply voltage (Front: pin #1, #29 / Back: pin #2, #30)
  • GND – This is the common ground for all power and logic (Front: pin #3, #27 / Back: pin #4, #28)

You can also hack the power pins to power the Carduino with a regulated 3.3V or 5V power source.

GPIO pins

This is the general purpose I/O pin set for the Carduino. GPIO consists of digital, analog, I2C, SPI, and UART pins. Most pins can do PWM output. Also, all pins can be used as interrupt pins.

  • Digital (Front: pin #9, #11, #21 / Back: pin #10, #12, #22)
  • Analog (Front: pin #13, #19 / Back: pin #14, #20)

I2C pins

You can use I2C pins allow Carduino to communicate with all the Longan cards (all cards are I2C enabled and comes with a factory default unique I2C address).

  • SDA – The I2C data pin (Front: pin #5, #25 / Back: pin #6, #26)
  • SCL – The I2C clock pin (Front: pin #7, #23 / Back: pin #8, #24)

Hardware SPI pins

These are the hardware SPI pins that can be used to communicate with high speed.

  • SCK – Serial Clock (Front: pin #17)
  • MISO - Master In Slave Out, takes data from the Carduino to the SPI device (Front: pin #15)
  • MOSI – Master Out Slave In, takes data to the Carduino from the SPI device (Back: pin #16)

Hardware UART / Serial

These pins can be used to connect devices support with UART using two wires.

  • TX – Transmits data (Front: pin #21)
  • RX – Receives data (Back: pin #22)

Arduino IDE Setup

First download the Arduino IDE from https://www.arduino.cc/en/Main/Software. Arduino IDE can be installed and run on Windows, Linux, and Mac OS X operating systems. Download the installer or zip file (Windows only) and install (if you have the zip file, extract it to your Windows computer’s hard drive) it on your operating system.

Once finished, start the Arduino IDE.

Copy and paste the link below into the Additional Boards Manager URLs option in the Arduino IDE preferences (File > Preferences).

https://raw.githubusercontent.com/Longan-Labs/Longan-Board/master/package_longan_boards_index.json

The Longan AVR boards supplied package includes supports for Longan Card, Carduino 328, Carduino 32U4.

Once done, click OK button to save the new preference settings.

Now open the Boards Manager by navigating to the Tools -> Board menu.

Select All from the Type drop-down menu. Then type longan in the top search bar. While typing, you will see the Longan AVR package.

Click on the Longan AVR by Longan Labs and then click on Install button.

Once installed, close the Boards Manager window.

How to Use

Carduino can be plugged in to one of the edge connector slots available in the following boards.

  • Game board
  • Car board
  • Sensor display board
  • Extension board
  • Pi Hap

All Longan cards are polarized, and every pin is unique in terms of both location and function. On the front side of the Carduino, a white arrow is printed near the edge connector indicates the pin #1.

Using with Extension Board

We will be using Longan Extension board demonstrate how you can insert the Carduino in to an edge connector slot.

  • Take the Carduino and Extension board. Then plug the Carduino into the edge connector slot of the Extension board as shown in the picture below.

  • Next, take the AAA battery card and insert two 1.5V or 1.2V, AAA sized batteries.

  • Then insert it in to another edge connector slot on the Extension board. Make sure to slide the power switch of the battery card to the ON position.

  • Now your Carduino can use the battery power to function correctly.

We will start off with something very simple with an LED, turning on and off, repeatedly, producing a pleasant blinking effect. The Carduino has a built-in LED on digital pin 13 (Arduino Leonardo equivalent) emits bright blue light when turned on. You can find it on the front of the Carduino (labelled as D13) very close to the Type-C USB connector.

Now you can upload your first Blink sketch to the Carduino. The Arduino IDE provides a great example for blinking a LED. There is no need to type anything, just click File > Example > 01.Basics > Blink under Built-in Examples in the Arduino IDE.

Connect the Type-C USB cable to the USB connector of the Carduino and connect the other end to your computer.

Next, tell the Arduino IDE to use the Carduino. To do this, click Tools > Board > Carduino 32U4 under Longen AVR Boards.

Then select the proper port in Tools > Port > (the Serial/COM port of your Carduino).

Next, upload the program by clicking Sketch > Upload.

It will take some time to compile and upload the sketch in to the Carduino.

If you have trouble loading the Blink sketch from the examples, you can copy and paste the code below into the Arduino editor.

/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs repeatedly forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

After uploading the sketch to the Carduino, you should see the LED on the Carduino blinking.

When you press the reset button during running your sketch, the Carduino will take some time to re-start the program and blinks the LED very slowly with a fading effect.

Now, you can firmly remove the Type-C USB cable from the Carduino to allow to use the battery power with the Longan AAA battery card. When you remove the USB power, the Carduino will automatically switch to the battery power and continually executes the program without resetting the microcontroller.

If you want to turn off the Carduino, simply slide the switch to the off position on the AAA battery card.

Resources