Skip to content

All items ship from our office in Colorado USA - $5.95 Flat-Rate US shipping & free shipping on orders over $75!

Teensy 4.0 ARM Cortex-M7 Microcontroller Development Board User Guide

Teensy 4.0 ARM Cortex-M7 Microcontroller Development Board

📋 Overview

The PJRC Teensy 4.0 is a compact, high-performance microcontroller development board built around the NXP IMXRT1062 ARM Cortex-M7 processor running at 600 MHz. It packs extraordinary processing power — rivaling many microcomputers — into the same tiny, breadboard-friendly footprint as the popular Teensy 3.2 (just 1.4 × 0.7 inches).

With 2MB of flash memory, 1MB of RAM, hardware floating point for both 32-bit and 64-bit math, and a rich set of peripherals including 7 serial ports, 3 SPI, 3 I2C, and 3 CAN Bus, the Teensy 4.0 is ideal for projects that demand serious performance in a small package. And like all Teensy boards, it's programmed using the familiar Arduino IDE.

⚠️ Important: All Teensy 4.0 I/O pins operate at 3.3V. The pins are not 5V tolerant. Do not apply more than 3.3V to any digital or analog pin, or you may permanently damage the board.

💡 Teensy 4.0 vs. Teensy 4.1: The Teensy 4.0 and 4.1 share the same 600 MHz ARM Cortex-M7 processor and 1MB of RAM. The key differences are size and peripherals: the Teensy 4.1 is larger (2.4 × 0.7 inches), has 4× more flash memory (8MB vs 2MB), and adds a built-in Ethernet PHY, microSD card socket, and a USB host port with power management. If you need Ethernet, onboard SD storage, or more I/O pins, consider the Teensy 4.1. If you want maximum performance in the smallest possible footprint, the Teensy 4.0 is the one.


🛠️ What You'll Need

Required

  • USB Micro-B Cable — For programming and powering the board. Make sure it's a data cable, not a charge-only cable.
  • Computer — Windows 10/11, macOS, or Linux with a USB port.
  • Arduino IDE — Version 2.0.4 or later recommended (free download from arduino.cc).

Recommended

  • Header Pins (2x 14-pin strips) — Required for breadboard use. Soldering is required.
  • Soldering Iron & Solder — For attaching header pins.
  • Solderless Breadboard — For prototyping circuits.
  • Jumper Wires — For making connections on the breadboard.

Optional Accessories

  • CR2032 Coin Cell Battery — For maintaining the Real-Time Clock (RTC) while power is off.
  • PJRC Audio Shield (Rev D) — For high-quality stereo audio input and output.
  • USB Host Cable — For connecting USB devices to the Teensy's host port (requires soldering to bottom-side SMT pads).

🔧 Board Overview

The Teensy 4.0 maintains the same compact form factor as the Teensy 3.2 — measuring approximately 1.4 × 0.7 inches (36 × 18 mm). It's a direct drop-in upgrade in processing power, retaining compatibility with most pin functions from the Teensy 3.2.

Key Components on the Board

  • NXP IMXRT1062 Processor — The main ARM Cortex-M7 chip (144-pin package), located in the center of the board.
  • 2MB Flash Memory Chip — Stores your program code (W25Q16JV).
  • USB Micro-B Connector — The main USB port for programming and communication with your computer.
  • Program Button — A small pushbutton used to enter bootloader mode for programming. This is not a reset button.
  • Orange LED — Connected to Pin 13. Blinks slowly on brand-new boards running the factory-loaded blink program.
  • Red LED — Dedicated bootloader status indicator. Dim when the bootloader is waiting; bright while writing to flash.
  • VBAT Pads — For connecting a CR2032 coin cell to power the RTC while the board is off.
  • On/Off Pin — For connecting a pushbutton to control power state (hold 4 seconds to power off, press briefly to power on).
  • Bottom-Side SMT Pads — 16 additional pads on the underside provide access to USB host, SD card (via SDIO), and extra I/O pins (pins 24–33). These require soldering.

Understanding the Two Programs on Your Teensy

Every Teensy contains two programs:

  1. Your User Program — This is the code you write and upload. On a brand-new board, this is a simple LED blink program.
  2. The Bootloader — This is a special program stored on a separate chip that handles uploading new code. You enter bootloader mode by pressing the Program button.

The bootloader is stored on a dedicated chip, completely separate from your program. This means you can never accidentally erase or damage the bootloader — the Teensy can always be reprogrammed, even if you upload code that crashes.


📌 Pinout Reference

The Teensy 4.0 has 40 total I/O pins. When used on a breadboard, 24 pins are accessible along the two outer edges. An additional 16 pins are available as SMT pads on the bottom of the board (these require soldering).

A double-sided pinout reference card is included with every Teensy 4.0, and is printed below.

Teensy 4.0 Pinout Reference Card Front & Back

You can also download printable versions from PJRC:

📝 Note: Not shown on the reference card: Pin 0 also functions as CS1, and Pin 1 also functions as MISO1.

Pin Capabilities Summary

Function Pins Notes
Digital I/O All 40 pins 3.3V output, not 5V tolerant
PWM Output 31 pins 19 independent frequency groups
Analog Input 14 pins Up to 12-bit resolution (10-bit usable)
Serial (UART) 7 ports All have FIFOs for high-speed performance
SPI 3 ports First port has FIFO for faster transfers
I2C 3 ports Supports 100, 400, and 1000 kbit/sec
CAN Bus 3 ports 1 port supports CAN-FD
I2S/TDM Audio 2 ports Up to 16 channels per pin using TDM
S/PDIF 1 input, 1 output Independent of I2S ports
USB Host 2 SMT pads (bottom) No power management — do not hot-plug
LED Pin 13 Orange LED, active HIGH

Bottom-Side SMT Pads

The Teensy 4.0 has 16 SMT pads on the bottom of the board that provide access to additional functionality:

  • Pins 24–33 — Additional digital I/O, PWM, serial, and other functions.
  • USB Host (D+ and D−) — Two pads for connecting USB devices in host mode.
  • SD Card (SDIO) — Eight pads for connecting an SD card using the fast 4-bit SDIO protocol.

These pads require surface-mount soldering skills to use. For projects that need easy access to these features, consider the Teensy 4.1, which breaks out these signals on through-hole pins and includes a built-in SD card socket.

Important Pin Notes

  • All pins are 3.3V only. Do not connect 5V signals directly to any pin.
  • Pin 13 has the onboard orange LED connected. When using pin 13 as an input, the external signal must be able to drive the LED. Do not use INPUT_PULLUP with pin 13.
  • All digital pins support interrupts via attachInterrupt().
  • All digital pins have optional pullup, pulldown, or keeper resistors, configured with pinMode().
  • Recommended maximum output current per pin is 4mA (output HIGH is 3.3V).

🚀 Getting Started

Step 1: Plug In Your Teensy

Connect the Teensy 4.0 to your computer using a USB Micro-B cable. All brand-new Teensy boards come with an LED blink program pre-loaded — you should see the orange LED on pin 13 blinking slowly (1 second on, 1 second off).

If the LED doesn't blink, check that your USB cable is a data cable (not charge-only) and try a different USB port.

Step 2: Install Arduino IDE

Download and install the Arduino IDE from arduino.cc. Version 2.3.0 or later is recommended.

Step 3: Install the Teensy Boards Add-on

  1. Open Arduino IDE.
  2. Go to File > Preferences (on macOS: Arduino IDE > Settings).
  3. In the "Additional boards manager URLs" field, paste this URL:
    https://www.pjrc.com/teensy/package_teensy_index.json
  4. Click OK.
  5. Open the Boards Manager by clicking the board icon on the left sidebar.
  6. Search for "teensy".
  7. Click Install on the Teensy package.

This installs the Teensyduino add-on, which includes the Teensy Loader application and a large collection of optimized libraries.

Step 4: Select Your Board

  1. Go to Tools > Board and select Teensy 4.0 from the Teensy section.
  2. Go to Tools > Port and select the port that corresponds to your Teensy.
  3. Leave Tools > USB Type set to Serial (the default) for now.
  4. Leave Tools > CPU Speed set to 600 MHz (the default).

Step 5: Upload Your First Program

Let's upload the classic LED blink sketch to confirm everything is working:

  1. Go to File > Examples > 01.Basics > Blink.
  2. Click the Upload button (right arrow icon).
  3. The Arduino IDE will compile your code and the Teensy Loader will automatically upload it to your board.
  4. You should see the orange LED blinking — confirming that your setup is working correctly.

💡 Tip: If the upload doesn't start automatically, press the Program button on the Teensy to manually enter bootloader mode. The red LED will glow dimly, indicating the bootloader is ready to receive code.


💻 Example Code

Example 1: LED Blink (Basic)

This is the simplest possible Teensy program — it blinks the onboard LED on pin 13.

// Teensy 4.0 — LED Blink
// Blinks the onboard orange LED on Pin 13

const int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);   // LED on
  delay(1000);                  // Wait 1 second
  digitalWrite(ledPin, LOW);    // LED off
  delay(1000);                  // Wait 1 second
}

Example 2: Serial Monitor Communication

This example demonstrates sending data from the Teensy to your computer via USB Serial. Open the Arduino Serial Monitor (Tools > Serial Monitor) after uploading.

// Teensy 4.0 — Serial Monitor Example
// Prints a message and the board's uptime to the Serial Monitor

void setup() {
  Serial.begin(9600);  // Baud rate is ignored on Teensy USB Serial
                       // but included for Arduino compatibility
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  Serial.print("Teensy 4.0 is running. Uptime: ");
  Serial.print(millis() / 1000);
  Serial.println(" seconds");
  digitalWrite(13, LOW);
  delay(2000);
}

💡 Note: On Teensy, USB Serial runs at full USB speed regardless of the baud rate setting. The Serial.begin(9600) line is included for compatibility but the actual transfer speed is much faster.

Example 3: Reading an Analog Sensor

This example reads an analog value from pin A0 (pin 14) and prints it to the Serial Monitor. You can connect a potentiometer or any analog sensor to test this.

// Teensy 4.0 — Analog Read Example
// Reads analog input on pin A0 and prints the value

const int sensorPin = A0;  // Pin 14 on Teensy 4.0

void setup() {
  Serial.begin(9600);
  analogReadResolution(10);  // 10-bit resolution (0-1023)
                             // Hardware supports 12-bit, but 10-bit
                             // is more practical due to noise
}

void loop() {
  int sensorValue = analogRead(sensorPin);
  float voltage = sensorValue * (3.3 / 1023.0);

  Serial.print("Raw: ");
  Serial.print(sensorValue);
  Serial.print("  Voltage: ");
  Serial.print(voltage, 2);
  Serial.println(" V");

  delay(500);
}

⚠️ Important: The analog input range is fixed at 0 to 3.3V. The analogReference() function has no effect on Teensy 4.0. Do not apply more than 3.3V to any analog pin.


📡 USB Device Types

One of the Teensy 4.0's most powerful features is its ability to appear as many different types of USB devices to your computer. This is configured in the Arduino IDE under Tools > USB Type.

USB Type Description Typical Use
Serial Appears as a COM port / serial device General communication, debugging, data logging
Keyboard Standard 104-key USB keyboard Sending keystrokes to control software
Mouse USB mouse with relative and absolute positioning Custom pointing devices, digitizer pens
Joystick Game controller with 6 axes, 32 buttons, hat switch Flight sim panels, custom game controllers
MIDI Class-compliant MIDI device Music controllers, synthesizers, DAW integration
Audio USB sound card (stereo in/out) Audio processing with the Teensy Audio Library
MTP Disk Media Transfer Protocol (like a phone/camera) File sharing from flash or external storage
Raw HID 64-byte message packets Custom communication with PC software
Flight Sim X-Plane flight simulator integration Custom cockpit controls and instruments
Touchscreen Multi-touch (up to 10 fingers) Custom touch input devices

Several USB types can be combined (e.g., "Serial + Keyboard + Mouse + Joystick") to create multi-function USB devices.


🔋 Memory Architecture

The Teensy 4.0 has a sophisticated memory system designed to keep the 600 MHz processor running at full speed. Here's a simplified overview:

Memory Type Size Purpose
Flash (Program) 2 MB (1984K usable) Stores your compiled program code and read-only data
RAM1 (TCM) 512K Ultra-fast tightly coupled memory for code and variables
RAM2 512K Optimized for DMA access — large arrays and buffers go here
EEPROM 1080 bytes Emulated non-volatile storage for settings and calibration data

📝 Note: Unlike the Teensy 4.1, the Teensy 4.0 does not have QSPI memory expansion pads for adding external PSRAM or flash chips. If your project requires more than 2MB of program storage or needs external RAM, consider the Teensy 4.1.

Memory Keywords

The Teensy toolchain provides special keywords to control where your variables and functions are placed in memory:

  • DMAMEM — Place large arrays and buffers in RAM2, freeing up the faster RAM1 for normal variables.
  • PROGMEM / F() — Place read-only data in flash memory only.
  • FASTRUN — Place functions in RAM1 for fastest execution (this is the default for most functions).
  • FLASHMEM — Place functions in flash memory (slower, but saves RAM1 space — good for setup code).

🔌 USB Host Port

The Teensy 4.0 includes a USB host port that allows you to connect USB devices — keyboards, mice, MIDI controllers, joysticks, and more — directly to the Teensy. The host port operates independently of the main USB device port, so you can communicate with USB devices and your computer simultaneously.

Important Differences from Teensy 4.1

  • The USB host port on the Teensy 4.0 is accessed via two small SMT pads on the bottom of the board (D+ and D−). Soldering is required.
  • The Teensy 4.0 does not have power management circuitry for the USB host port — it provides data pins only. You must provide 5V power to the connected USB device separately.
  • Do not hot-plug USB devices when the Teensy 4.0 is powered by a USB cable or limited power supply. Connect devices before powering on.

The USBHost_t36 library is used to communicate with USB devices connected to the host port. USB hubs are supported, allowing multiple devices to be connected.


💾 Using an SD Card

The Teensy 4.0 does not have a built-in SD card socket like the Teensy 4.1. However, there are two ways to add SD card storage:

Option 1: SPI-Based SD Card (Easiest)

Connect an SD card breakout board to the SPI pins. This uses the slower single-bit SPI protocol but requires no special soldering.

// Teensy 4.0 — SD Card via SPI
#include <SD.h>

const int chipSelect = 10;  // CS pin for your SD breakout

void setup() {
  Serial.begin(9600);
  while (!Serial) { }

  Serial.print("Initializing SD card... ");

  if (!SD.begin(chipSelect)) {
    Serial.println("SD card initialization failed!");
    return;
  }
  Serial.println("SD card initialized.");

  // Write a file
  File myFile = SD.open("test.txt", FILE_WRITE);
  if (myFile) {
    myFile.println("Hello from Teensy 4.0!");
    myFile.close();
    Serial.println("File written successfully.");
  }
}

void loop() {
  // Nothing here
}

Option 2: SDIO via Bottom Pads (Faster)

The Teensy 4.0 has 8 SMT pads on the bottom of the board for connecting an SD card using the fast 4-bit native SDIO protocol. This requires surface-mount soldering skills but provides significantly faster data transfer. When using SDIO, initialize with SD.begin(BUILTIN_SDCARD).


🔋 Power

Powering the Board

  • USB Power (default): The Teensy is normally powered through the USB cable from your computer or a USB power supply. Power arrives at the VUSB pin, which is connected to VIN.
  • VIN Pin: When USB is not connected, you can apply 5V to the VIN pin. Do not apply power to VIN while USB is connected, unless you cut the VUSB-VIN trace on the bottom of the board.
  • 3.3V Regulator: An onboard regulator converts the 5V input to 3.3V for the processor and peripherals. You can draw up to 250mA from the 3.3V pin for external circuits.

Power Consumption

  • Approximately 100 mA at 600 MHz.
  • Reducing CPU speed (via Tools > CPU Speed) reduces power consumption.
  • At 24 MHz, the CPU runs on only 0.95V, significantly reducing power draw.

On/Off Control

The Teensy 4.0 has a dedicated On/Off pin for low-power or battery-operated projects:

  • Connect a pushbutton between the On/Off pin and GND.
  • Hold 4 seconds while running to turn off the 3.3V power supply.
  • Press briefly (0.5 seconds) while off to turn power back on.
  • If a coin cell is connected to VBAT, the power state is remembered when main power is disconnected.

VBAT (Battery Backup)

Connect a CR2032 coin cell between the VBAT and GND pads to keep the Real-Time Clock running while the board is powered off. The RTC will maintain accurate date and time, and 16 bytes of battery-backed RAM (registers LPGPR0–LPGPR3) will be preserved.

USB Host Power Warning

⚠️ Important: Unlike the Teensy 4.1, the Teensy 4.0 does not have power management circuitry for the USB host port. The host port provides data signals only. Do not hot-plug USB devices when powered from a USB cable or limited power supply, as the inrush current can disrupt the Teensy's power.


📊 Specifications

Processor NXP IMXRT1062 (ARM Cortex-M7)
Package 144-pin LQFP
Clock Speed 600 MHz (overclockable to 912 MHz)
Architecture Dual-issue superscalar, branch prediction, 32K+32K cache
Floating Point Unit Hardware 32-bit (float) & 64-bit (double)
Flash Memory 2 MB (1984K usable for programs)
RAM 1024K total (512K tightly coupled + 512K DMA-optimized)
EEPROM 1080 bytes (emulated)
Digital I/O Pins 40 total (24 breadboard-friendly + 16 bottom SMT pads)
PWM Outputs 31
Analog Inputs 14 (up to 12-bit resolution, 10-bit usable)
Serial Ports (UART) 7 (all with FIFOs)
SPI Ports 3
I2C Ports 3 (100/400/1000 kbit/sec)
CAN Bus 3 (1 with CAN-FD)
USB Device 480 Mbit/sec (High Speed)
USB Host 480 Mbit/sec (via bottom SMT pads, no power management)
Ethernet None (available on Teensy 4.1)
SD Card Via bottom SMT pads (SDIO) or SPI
Digital Audio 2× I2S/TDM + 1× S/PDIF in + 1× S/PDIF out + MQS
DMA Channels 32 general purpose
Timers 4 interval timers, 32 PWM timers, 4 quadrature encoders, RTC
Security Cryptographic acceleration, random number generator, code security (Lockable variant)
Operating Voltage 3.3V (onboard regulator from 5V USB/VIN)
I/O Voltage 3.3V (not 5V tolerant)
Max Output Current (per pin) 4 mA recommended
Max 3.3V External Load 250 mA
Power Consumption ~100 mA at 600 MHz
Board Dimensions Approx. 36 × 18 mm (1.4 × 0.7 inches) L × W
Regulatory Compliance FCC, ISED, CE, UKCA, RoHS, REACH

📏 Teensy 4.0 vs. Teensy 4.1 — Quick Comparison

Both boards share the same 600 MHz ARM Cortex-M7 processor and 1MB of RAM. Here's what's different:

Feature Teensy 4.0 Teensy 4.1
Board Size 1.4 × 0.7 in (36 × 18 mm) 2.4 × 0.7 in (61 × 18 mm)
Flash Memory 2 MB 8 MB
EEPROM 1080 bytes 4284 bytes
Breadboard I/O 24 pins 42 pins
Total I/O 40 pins 55 pins
PWM Outputs 31 35
Analog Inputs 14 18
Serial Ports 7 8
Ethernet None 10/100 Mbit (built-in PHY)
SD Card Via bottom SMT pads or SPI Built-in microSD socket (SDIO)
USB Host 2 SMT pads (no power mgmt) 5 pins with power management
QSPI Memory Expansion Program memory only 2 chip locations (up to 16MB PSRAM)

Choose the Teensy 4.0 when you need maximum performance in the smallest possible footprint, or as a drop-in upgrade from a Teensy 3.2. Choose the Teensy 4.1 when you need Ethernet, onboard SD storage, more I/O, or expandable memory.


🛠️ Troubleshooting

Problem Possible Cause Solution
LED doesn't blink on new board Bad USB cable or port Try a different USB cable (make sure it's a data cable, not charge-only). Try a different USB port or computer.
Teensy not recognized by Arduino IDE Teensyduino not installed Install the Teensy boards add-on via Boards Manager using the PJRC JSON URL (see Getting Started, Step 3).
Upload fails or hangs Board not in bootloader mode Press the Program button on the Teensy to manually enter bootloader mode. The red LED should glow dimly.
Serial Monitor shows nothing Wrong port selected, or code doesn't use Serial Check Tools > Port. Make sure your code includes Serial.begin() and Serial.print() statements. Try adding while (!Serial) { } in setup() to wait for the connection.
Analog readings are noisy or inaccurate Noise, floating pin, or 5V signal Ensure the signal is 0–3.3V. Use a low-impedance source. Consider averaging multiple readings. Use 10-bit resolution (the practical limit).
Board appears "bricked" or unresponsive Bad code uploaded Press and hold the Program button for 15 seconds (between 13–17 seconds). This performs a Memory Wipe, erasing all code and restoring the LED blink program. The red LED will flash to indicate the erase window.
5V device not working with Teensy Voltage mismatch Teensy 4.0 is 3.3V only and not 5V tolerant. Use a level shifter between the Teensy and any 5V device.
USB host device not working No power to device, or hot-plugged The Teensy 4.0 USB host port has no power management. Provide 5V power to the USB device separately. Connect the device before powering on the Teensy.

Memory Wipe & LED Blink Restore

If your Teensy becomes completely unresponsive due to bad code, you can perform a full memory wipe:

  1. Press and hold the Program button.
  2. The red LED will flash briefly after about 13 seconds — this marks the beginning of the erase window.
  3. Continue holding until the red LED turns on bright (flash is being erased).
  4. Release the button after the red LED turns off (around 17 seconds total).
  5. The Teensy will reboot and run the built-in LED blink program.

This erases all non-volatile memory and restores the factory LED blink program. Your bootloader is never affected — it's on a separate chip.


🔌 Compatible With

  • Arduino IDE 2.x (with Teensyduino boards add-on via Boards Manager)
  • Arduino IDE 1.8.x (with Teensyduino installer — Windows and Linux only)
  • PlatformIO IDE (Windows, Mac, Linux)
  • Visual Micro for Microsoft Visual Studio (Windows only, commercial)
  • CircuitPython (partial hardware support)
  • PJRC Audio Shield (Rev D)
  • SmartLED Shield v5 for HUB75 RGB LED panels
  • Standard solderless breadboards (same footprint as Teensy 3.2)

🎯 Common Applications

  • Audio Processing — Multi-channel audio synthesis, effects processing, and streaming using the Teensy Audio Library and Audio Shield.
  • LED Installations — Drive thousands of WS2812B/NeoPixel LEDs at video refresh rates using the OctoWS2811 library, or large HUB75 RGB panels with SmartMatrix.
  • Custom USB Devices — Build keyboards, MIDI controllers, joysticks, flight sim panels, and other HID devices.
  • Automotive & Industrial — CAN Bus communication for vehicle diagnostics, industrial control, and automation.
  • Signal Processing — Real-time DSP, FFT analysis, and digital filtering using the hardware DSP instructions.
  • Robotics — Multi-axis motor control with 31 PWM channels, sensor fusion, and real-time control loops.
  • DMX Lighting — Control DMX lighting fixtures using any of the 7 serial ports.
  • Drop-in Upgrade — Replace a Teensy 3.2 with dramatically more processing power in the same footprint.
  • Commercial Products — Secure embedded systems using the Lockable variant with encrypted firmware updates.

🏪 Where to Buy

The Teensy 4.0 and compatible accessories are available at Envistia Mall.

  • 📦 Fast US Shipping
  • 🔄 Hassle-Free Returns
  • 📧 Responsive Customer Support

📚 Additional Resources


This user guide is provided by Envistia Mall for informational purposes. While we strive for accuracy, specifications and features may change without notice. Always refer to the manufacturer's official documentation for the most current information. The manufacturer and Envistia LLC (dba Envistia Mall) are not responsible for any damages or losses resulting from the use of this product. Always follow proper electrical safety practices when working with electronic components.

Share this guide:
in

🛒 Related Products

Find the components mentioned in this guide in our store.

Browse Products →