

The ATTINY402 is a low-power 8-bit microcontroller manufactured by Microchip Technology. It is part of the ATtiny family and is designed for compact, energy-efficient applications. With 4KB of Flash memory, 256 bytes of SRAM, and a 12-bit ADC, the ATTINY402 is ideal for small, battery-operated devices. It supports multiple communication protocols, making it versatile for a wide range of embedded systems.








| Parameter | Value |
|---|---|
| Architecture | 8-bit AVR |
| Flash Memory | 4KB |
| SRAM | 256 bytes |
| EEPROM | 128 bytes |
| Operating Voltage | 1.8V to 5.5V |
| CPU Speed | Up to 20 MHz |
| ADC Resolution | 12-bit |
| Communication Interfaces | USART, SPI, I2C (TWI) |
| GPIO Pins | 11 |
| Power Consumption | Ultra-low power (varies by mode) |
| Package | SOIC, QFN, or DFN |
The ATTINY402 is available in an 8-pin package. Below is the pinout and description:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VDD | Power supply (1.8V to 5.5V) |
| 2 | GND | Ground |
| 3 | PA0 | GPIO, ADC input, or alternate function |
| 4 | PA1 | GPIO, ADC input, or alternate function |
| 5 | PA2 | GPIO, ADC input, or alternate function |
| 6 | PA3 | GPIO, ADC input, or alternate function |
| 7 | PA4 | GPIO, ADC input, or alternate function |
| 8 | RESET | Reset pin (active low) |
Although the ATTINY402 is not directly programmable via Arduino IDE, it can be programmed using the Arduino ecosystem with the appropriate core installed. Below is an example of toggling an LED connected to PA0:
// Include necessary libraries for ATTINY402
#include <avr/io.h>
#include <util/delay.h>
#define LED_PIN 0 // PA0 is pin 0 on ATTINY402
int main(void) {
// Set PA0 as output
PORTA.DIR |= (1 << LED_PIN);
while (1) {
// Toggle LED
PORTA.OUT ^= (1 << LED_PIN);
_delay_ms(500); // Delay for 500ms
}
return 0;
}
Note: Ensure you have installed the ATTINY402 core in the Arduino IDE and are using a UPDI programmer for uploading the code.
Microcontroller Not Responding
Programming Failure
GPIO Pins Not Functioning
High Power Consumption
Q: Can the ATTINY402 be programmed using the Arduino IDE?
A: Yes, with the appropriate ATTINY402 core installed and a UPDI programmer, you can program it using the Arduino IDE.
Q: What is the maximum clock speed of the ATTINY402?
A: The ATTINY402 can operate at a maximum clock speed of 20 MHz.
Q: Does the ATTINY402 support external oscillators?
A: No, the ATTINY402 uses an internal oscillator and does not support external oscillators.
Q: How many ADC channels are available?
A: The ATTINY402 has up to 5 ADC channels, depending on the pin configuration.
Q: Can the ATTINY402 operate at 1.8V?
A: Yes, the ATTINY402 supports an operating voltage range of 1.8V to 5.5V.