

The Leonardo ICSP (In-Circuit Serial Programming) is a programming interface designed for Arduino Leonardo boards. It provides a direct connection to the microcontroller via the SPI (Serial Peripheral Interface) protocol, enabling users to upload sketches, program the microcontroller, and establish communication for advanced applications. The ICSP header is particularly useful for bootloader programming, firmware updates, and interfacing with external SPI devices.








The Leonardo ICSP header consists of 6 pins arranged in a 2x3 configuration. Below is the pinout and description:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | MISO | Master In Slave Out - Data sent from the microcontroller to the programmer. |
| 2 | VCC | Power supply for the ICSP interface (5V). |
| 3 | SCK | Serial Clock - Synchronizes data transfer between devices. |
| 4 | MOSI | Master Out Slave In - Data sent from the programmer to the microcontroller. |
| 5 | RESET | Resets the microcontroller for programming or bootloader access. |
| 6 | GND | Ground connection. |
[1] MISO [2] VCC
[3] SCK [4] MOSI
[5] RESET [6] GND
Connecting the ICSP Header:
Programming the Microcontroller:
Interfacing with SPI Devices:
SPI library in the Arduino IDE to communicate with the connected device.Below is an example of using the ICSP header to communicate with an SPI device (e.g., an SPI-based temperature sensor):
#include <SPI.h> // Include the SPI library
const int chipSelectPin = 10; // Define the chip select pin
void setup() {
// Initialize the SPI bus
SPI.begin();
// Set the chip select pin as output
pinMode(chipSelectPin, OUTPUT);
// Deselect the SPI device
digitalWrite(chipSelectPin, HIGH);
Serial.begin(9600); // Start serial communication for debugging
}
void loop() {
// Select the SPI device
digitalWrite(chipSelectPin, LOW);
// Send a command to the SPI device
byte response = SPI.transfer(0x01); // Replace 0x01 with your command
// Deselect the SPI device
digitalWrite(chipSelectPin, HIGH);
// Print the response from the SPI device
Serial.print("Response: ");
Serial.println(response, HEX);
delay(1000); // Wait for 1 second before the next communication
}
Issue: The programmer is not detected by the Arduino IDE.
Issue: Unable to upload sketches via the ICSP header.
Issue: SPI device not responding.
Issue: Bootloader update fails.
Q: Can I use the ICSP header for both programming and SPI communication simultaneously?
A: It is not recommended, as it may cause conflicts. Use separate SPI pins if possible.
Q: What happens if I connect the ICSP header incorrectly?
A: Incorrect connections can damage the microcontroller or the programmer. Always double-check the pin alignment.
Q: Is the ICSP header compatible with other Arduino boards?
A: The ICSP header is a standard interface, but the pinout and voltage levels may vary between boards. Always refer to the specific board's documentation.
Q: Can I power the Arduino Leonardo through the ICSP header?
A: No, the ICSP header provides power to the programmer but is not intended to power the board. Use the USB or external power jack for powering the board.