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!
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.
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.
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.
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.
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
Power Supply: Connect the VDD pin to a stable power source (1.8V to 5.5V) and the GND pin to ground.
Programming: Use an external programmer (e.g., Atmel ICE) to upload firmware via the UPDI (Unified Program and Debug Interface) pin.
GPIO Configuration: Configure the GPIO pins (PA0 to PA4) as input or output in your firmware, depending on your application.
Communication: Utilize the USART, SPI, or I2C interfaces for communication with other devices.
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
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.
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.
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.
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.