Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use ATTINY402: Examples, Pinouts, and Specs

Image of ATTINY402
Cirkit Designer LogoDesign with ATTINY402 in Cirkit Designer

Introduction

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.

Explore Projects Built with ATTINY402

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
ATtiny-Controlled LED Blinker Circuit
Image of led: A project utilizing ATTINY402 in a practical application
This circuit consists of an ATtiny microcontroller that controls an LED through one of its GPIO pins (PB4). A resistor is connected in series with the LED to limit the current. The ATtiny is powered by a 3.3V battery, and the LED is designed to turn on when the ATtiny is powered up.
Cirkit Designer LogoOpen Project in Cirkit Designer
ATtiny85 and OLED Display Based Interactive Game with Buzzer and LED
Image of FIRST CIRCUIT: A project utilizing ATTINY402 in a practical application
This circuit is a simple interactive game system powered by a 5V battery, featuring an ATtiny85 microcontroller, an OLED display, a buzzer, an LED, and multiple pushbuttons. The OLED displays a menu with options to start a game, which is controlled by the ATtiny85. The buzzer and LED provide audio-visual feedback, and the pushbuttons are used for user input to navigate the menu and play the game.
Cirkit Designer LogoOpen Project in Cirkit Designer
ATmega328P-Based Sensor Hub with OLED Display and LIDAR
Image of TILTPCB: A project utilizing ATTINY402 in a practical application
This circuit features an Mtiny Uno ATmega328P microcontroller as its central processing unit, interfacing with a variety of sensors and peripherals. It includes a 0.96" OLED display and an MPU6050 accelerometer/gyroscope for user interface and motion sensing, respectively. The circuit also integrates a TF LUNA LIDAR for distance measurement, a DHT11 sensor for temperature and humidity readings, and uses a 9V battery with a 7805 voltage regulator for power management. Communication with a computer for programming and data exchange is facilitated by an Adafruit FTDI Friend module.
Cirkit Designer LogoOpen Project in Cirkit Designer
ATMEGA328 Battery-Powered LED Blinker with FTDI Programming
Image of Homemade Arduino using ATmega328: A project utilizing ATTINY402 in a practical application
This circuit is a basic microcontroller setup using an ATMEGA328, powered by a 5V battery, and includes an FTDI programmer for serial communication. It features a pushbutton for reset functionality and two LEDs controlled by the microcontroller, with one LED blinking at a 1-second interval as programmed.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with ATTINY402

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of led: A project utilizing ATTINY402 in a practical application
ATtiny-Controlled LED Blinker Circuit
This circuit consists of an ATtiny microcontroller that controls an LED through one of its GPIO pins (PB4). A resistor is connected in series with the LED to limit the current. The ATtiny is powered by a 3.3V battery, and the LED is designed to turn on when the ATtiny is powered up.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of FIRST CIRCUIT: A project utilizing ATTINY402 in a practical application
ATtiny85 and OLED Display Based Interactive Game with Buzzer and LED
This circuit is a simple interactive game system powered by a 5V battery, featuring an ATtiny85 microcontroller, an OLED display, a buzzer, an LED, and multiple pushbuttons. The OLED displays a menu with options to start a game, which is controlled by the ATtiny85. The buzzer and LED provide audio-visual feedback, and the pushbuttons are used for user input to navigate the menu and play the game.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of TILTPCB: A project utilizing ATTINY402 in a practical application
ATmega328P-Based Sensor Hub with OLED Display and LIDAR
This circuit features an Mtiny Uno ATmega328P microcontroller as its central processing unit, interfacing with a variety of sensors and peripherals. It includes a 0.96" OLED display and an MPU6050 accelerometer/gyroscope for user interface and motion sensing, respectively. The circuit also integrates a TF LUNA LIDAR for distance measurement, a DHT11 sensor for temperature and humidity readings, and uses a 9V battery with a 7805 voltage regulator for power management. Communication with a computer for programming and data exchange is facilitated by an Adafruit FTDI Friend module.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Homemade Arduino using ATmega328: A project utilizing ATTINY402 in a practical application
ATMEGA328 Battery-Powered LED Blinker with FTDI Programming
This circuit is a basic microcontroller setup using an ATMEGA328, powered by a 5V battery, and includes an FTDI programmer for serial communication. It features a pushbutton for reset functionality and two LEDs controlled by the microcontroller, with one LED blinking at a 1-second interval as programmed.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Wearable devices
  • IoT (Internet of Things) sensors and nodes
  • Battery-powered devices
  • Home automation systems
  • Small-scale robotics
  • Consumer electronics

Technical Specifications

Key Technical Details

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

Pin Configuration and Descriptions

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)

Usage Instructions

How to Use the ATTINY402 in a Circuit

  1. Power Supply: Connect the VDD pin to a stable power source (1.8V to 5.5V) and the GND pin to ground.
  2. Programming: Use an external programmer (e.g., Atmel ICE) to upload firmware via the UPDI (Unified Program and Debug Interface) pin.
  3. GPIO Configuration: Configure the GPIO pins (PA0 to PA4) as input or output in your firmware, depending on your application.
  4. Communication: Utilize the USART, SPI, or I2C interfaces for communication with other devices.
  5. ADC Usage: Use the 12-bit ADC for analog signal measurements by configuring the appropriate pins as ADC inputs.

Important Considerations and Best Practices

  • Decoupling Capacitor: Place a 0.1µF ceramic capacitor close to the VDD pin to stabilize the power supply.
  • Reset Pin: Ensure the RESET pin is pulled high with a pull-up resistor (e.g., 10kΩ) if not used.
  • Low-Power Modes: Take advantage of the ATTINY402's sleep modes to reduce power consumption in battery-operated devices.
  • Clock Configuration: Configure the internal oscillator for the desired clock speed (default is 20 MHz).

Example Code for Arduino UNO

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.

Troubleshooting and FAQs

Common Issues and Solutions

  1. Microcontroller Not Responding

    • Cause: Incorrect power supply or missing decoupling capacitor.
    • Solution: Verify the power supply voltage (1.8V to 5.5V) and add a 0.1µF capacitor near the VDD pin.
  2. Programming Failure

    • Cause: Incorrect UPDI connection or unsupported programmer.
    • Solution: Ensure the UPDI pin is correctly connected to the programmer and use a compatible tool like Atmel ICE.
  3. GPIO Pins Not Functioning

    • Cause: Pins not configured correctly in firmware.
    • Solution: Double-check the pin configuration in your code and ensure the pins are set as input or output as needed.
  4. High Power Consumption

    • Cause: Microcontroller not in low-power mode.
    • Solution: Use sleep modes and disable unused peripherals in your firmware.

FAQs

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.