ATtiny412 LED & Hall Sensor Project — Design Session with Claude¶
A full transcript of a design session covering the hardware, wiring, code, and PCB decisions for a self-contained node consisting of an ATtiny412 microcontroller, a Hall effect sensor, and an RGB LED, powered by a USB power bank.
1. Can the ATtiny412 Handle 2 Hall Sensors and 2 LEDs?¶
User: Can an ATtiny412 run 2 hall sensors and 2 LEDs?
Claude: Yes, the ATtiny412 can handle that — it has exactly enough pins if you plan carefully.
The ATtiny412 has 6 I/O pins (PA0–PA3, PB0–PB1), with PA0 reserved for UPDI programming by default. That leaves 5 usable GPIO pins:
| Pin | Use |
|---|---|
| PA1 | Hall sensor 1 (digital input) |
| PA2 | Hall sensor 2 (digital input) |
| PA3 | LED 1 (digital output) |
| PB0 | LED 2 (digital output) |
| PB1 | spare / power |
Hall sensors — Most Hall effect sensors (like the A3144 or SS49E) just need a digital input with a pull-up resistor. The ATtiny412 has internal pull-ups, so no external resistors are needed.
LEDs — The ATtiny412 can source/sink up to 40mA total and 20mA per pin, plenty for driving LEDs directly with a current-limiting resistor (typically 100–330Ω for 3.3V/5V).
Power — The ATtiny412 runs at 1.8–5.5V, so it's compatible with both 3.3V and 5V Hall sensors and LEDs.
PA0/UPDI — If you need a 6th I/O pin, PA0 can be reconfigured as GPIO after programming, but you'd lose the ability to reprogram via UPDI without a high-voltage programmer.
2. Clarifying the Pinout — User Shares ATtiny x12 Datasheet Image¶
User: (uploaded image: ATtiny x12 8-pin pinout diagram from datasheet)
Image shows the ATtiny x12 8-pin SOIC package with pins: VCC (1), PA6 (2), PA7 (3), PA1 (4), PA2 (5), PA0/UPDI (6), PA3 (7), GND (8).
I am not sure how the pins you mentioned align with the pinout I have.
Claude: Good catch! I gave you the ATtiny412 pinout, but your image shows the ATtiny x12 8-pin variant. Re-mapped using the actual pinout:
| Pin # | Port | Use |
|---|---|---|
| 1 | VCC | Power |
| 2 | PA6 | Hall sensor 1 (digital input) |
| 3 | PA7 | Hall sensor 2 (digital input) |
| 4 | PA1 | LED 1 (output) |
| 5 | PA2 | LED 2 (output) |
| 6 | PA0 | UPDI (programming) — leave alone |
| 7 | PA3 | Spare |
| 8 | GND | Ground |
Notes: - PA1 and PA2 both support PWM (~), useful for dimming LEDs - PA6 and PA7 are clean digital inputs, perfect for Hall sensors - Internal pull-ups on PA6/PA7 mean no external resistors needed for most Hall sensors
3. Designing the Dual Sensor/LED Behavior and Wiring Diagram¶
User: Yes, I would like each LED to be associated with 1 hall sensor. When the hall sensor is triggered it will light up, and the other LED will dim. When neither is triggered, the LEDs will randomly brighten and dim.
Claude: (generated wiring diagram showing ATtiny412 with 2 hall sensors, 2 LEDs, pull-up resistors)
Pin assignments: - PA6 → Hall sensor 1 input - PA7 → Hall sensor 2 input - PA1 → LED 1 PWM output - PA2 → LED 2 PWM output
#include <Arduino.h>
const int HALL1_PIN = PIN_PA6;
const int HALL2_PIN = PIN_PA7;
const int LED1_PIN = PIN_PA1;
const int LED2_PIN = PIN_PA2;
float led1Brightness = 128;
float led2Brightness = 128;
float led1Step = 1.2;
float led2Step = -1.1;
void setup() {
pinMode(HALL1_PIN, INPUT_PULLUP);
pinMode(HALL2_PIN, INPUT_PULLUP);
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
}
void loop() {
bool hall1 = !digitalRead(HALL1_PIN);
bool hall2 = !digitalRead(HALL2_PIN);
if (hall1 && !hall2) {
analogWrite(LED1_PIN, 255);
analogWrite(LED2_PIN, 20);
} else if (hall2 && !hall1) {
analogWrite(LED2_PIN, 255);
analogWrite(LED1_PIN, 20);
} else if (hall1 && hall2) {
analogWrite(LED1_PIN, 255);
analogWrite(LED2_PIN, 255);
} else {
led1Brightness += led1Step;
led2Brightness += led2Step;
if (led1Brightness >= 255 || led1Brightness <= 10) {
led1Step = -led1Step;
led1Step += random(-3, 4) * 0.1;
led1Step = constrain(led1Step, -3.0, 3.0);
}
if (led2Brightness >= 255 || led2Brightness <= 10) {
led2Step = -led2Step;
led2Step += random(-3, 4) * 0.1;
led2Step = constrain(led2Step, -3.0, 3.0);
}
led1Brightness = constrain(led1Brightness, 10, 255);
led2Brightness = constrain(led2Brightness, 10, 255);
analogWrite(LED1_PIN, (int)led1Brightness);
analogWrite(LED2_PIN, (int)led2Brightness);
delay(8);
}
}
Install megaTinyCore in Arduino IDE to target the ATtiny412 (Tools → Board → megaTinyCore → ATtiny412).
4. Identifying the Hall Sensors — User Shares DigiKey Bag Label¶
User: (uploaded image: DigiKey bag label showing part TLE493DA2B6HTSA1CT-ND)
Image shows a DigiKey anti-static bag containing 25 units of the Infineon TLE493DA2B6HTSA1, described as "SEN HALL EFFECT SPI PG-TSOP6-6-8". Ordered 20-MAR-2026.
These are the surface mount Hall sensors I want to use. Where do I find the datasheet for them? I need to find the footprint.
Claude: Those are Infineon TLE493DA2B6HTSA1 sensors — a 3D Hall effect sensor with SPI interface in a PG-TSOP6-6-8 package.
Datasheet sources:
- Infineon directly: https://www.infineon.com/cms/en/product/sensor/magnetic-sensors/magnetic-position-sensors/3d-magnetics/tle493d-a2b6/
- DigiKey product page — search TLE493DA2B6HTSA1CT-ND
- SnapEDA or Ultra Librarian for ready-made KiCad/Eagle footprints
Important heads-up — this sensor is quite different from what was planned. The TLE493D is a 3D magnetic field sensor with SPI, not a simple digital on/off Hall sensor. It communicates over SPI (MOSI, MISO, SCK, CS), requires reading X/Y/Z field strength values, and is meant for position/angle sensing. This would use most of the ATtiny412's pins for two sensors.
5. Choosing a Simpler Surface Mount Hall Sensor¶
User: I want simple magnetic detection that is surface mountable. What should I use?
Claude: Best options for simple on/off magnetic detection in SMD:
| Part | Package | Notes |
|---|---|---|
| AH3572 (Diodes Inc.) | SOT-23 | Best pick — simple 3-pin, very common |
| AH1806 (Diodes Inc.) | SOT-23 | Ultra low power, good for battery |
| DRV5023 (Texas Instruments) | SOT-23 | Excellent TI documentation, easy KiCad footprints |
All three are simple 3-pin (VCC, GND, OUT) and drop straight into the existing wiring plan.
6. Switching to the A1324LLHLT-T — Analog Hall Sensor¶
User: I will now use the A1324LLHLT-T SEN Hall Effect Anlg Volt SOT23W. What is the power input in this circuit?
Claude: The A1324LLHLT-T requires 4.5V to 5.5V — it must run at 5V and will not work at 3.3V.
Important — it is an analog sensor, not digital. Its output voltage varies proportionally with magnetic field strength. At rest with no magnet the quiescent output sits at 50% of VCC (~2.5V), rising or falling with field strength. This means:
- The circuit must run at 5V
- Code must use
analogRead()with a threshold instead ofdigitalRead()
The ATtiny412 pins PA1, PA2, PA6, PA7 are all ADC-capable, so it will work — but the code needs updating.
7. Updated Code for Analog Hall Sensor¶
User: Update code for now, because these are the sensors available to me.
#include <Arduino.h>
const int HALL1_PIN = PIN_PA6;
const int HALL2_PIN = PIN_PA7;
const int LED1_PIN = PIN_PA1;
const int LED2_PIN = PIN_PA2;
const int THRESHOLD = 80;
const int QUIESCENT = 512;
float led1Brightness = 128;
float led2Brightness = 128;
float led1Step = 1.2;
float led2Step = -1.1;
bool isTriggered(int pin) {
int val = analogRead(pin);
return abs(val - QUIESCENT) > THRESHOLD;
}
void setup() {
pinMode(HALL1_PIN, INPUT);
pinMode(HALL2_PIN, INPUT);
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
}
void loop() {
bool hall1 = isTriggered(HALL1_PIN);
bool hall2 = isTriggered(HALL2_PIN);
if (hall1 && !hall2) {
analogWrite(LED1_PIN, 255);
analogWrite(LED2_PIN, 20);
} else if (hall2 && !hall1) {
analogWrite(LED2_PIN, 255);
analogWrite(LED1_PIN, 20);
} else if (hall1 && hall2) {
analogWrite(LED1_PIN, 255);
analogWrite(LED2_PIN, 255);
} else {
led1Brightness += led1Step;
led2Brightness += led2Step;
if (led1Brightness >= 255 || led1Brightness <= 10) {
led1Step = -led1Step;
led1Step += random(-3, 4) * 0.1;
led1Step = constrain(led1Step, -3.0, 3.0);
}
if (led2Brightness >= 255 || led2Brightness <= 10) {
led2Step = -led2Step;
led2Step += random(-3, 4) * 0.1;
led2Step = constrain(led2Step, -3.0, 3.0);
}
led1Brightness = constrain(led1Brightness, 10, 255);
led2Brightness = constrain(led2Brightness, 10, 255);
analogWrite(LED1_PIN, (int)led1Brightness);
analogWrite(LED2_PIN, (int)led2Brightness);
delay(8);
}
}
Key changes:
- pinMode set to INPUT — no pull-up, the A1324 drives its own output
- isTriggered() reads analog value and checks deviation from 512 midpoint
- THRESHOLD = 80 — adjust to tune sensitivity
- Works with either pole of the magnet
8. Wiring Diagram Update — No Pull-up Resistors¶
User: Does my diagram change? You say no pull-up resistor.
Claude: Yes — the two 10kΩ pull-up resistors are removed. The A1324 actively drives its output pin.
(Updated wiring diagram generated — A1324 OUT connects directly to ATtiny412 analog input pins with no resistor in between)
Additional note: A 100nF decoupling capacitor is recommended between VCC and GND placed physically close to each sensor. The A1324 datasheet recommends this to filter noise on the supply line, which matters when reading analog voltages.
9. How to Wire a Decoupling Capacitor¶
User: How do I hook up a 100nF decoupling capacitor? Is this just a capacitor or are decoupling capacitors special?
Claude: A decoupling capacitor is just a regular capacitor — nothing special about the component itself. Any standard 100nF ceramic capacitor works. The "decoupling" part refers to how you use it, not what it is.
It goes directly between VCC and GND, as close to the sensor as physically possible on the PCB.
(Diagram generated showing capacitor connected between VCC and GND in parallel with the sensor's power pins)
Key notes: - Buy a 100nF (0.1µF) MLCC ceramic capacitor, 0402 or 0603 SMD package, 10V or higher rating - Ceramic capacitors have no polarity — either leg to VCC or GND, no wrong way round - Place as close to sensor as possible on the PCB — long traces reduce effectiveness - One cap per sensor — two total
10. UPDI Programming Interface Explained¶
User: What does UPDI connect to?
Claude: UPDI is the programming interface — how you upload code to the ATtiny412. It connects to your programmer.
The most common approach is a USB-to-serial adapter (CH340 or CP2102) with a single 4.7kΩ resistor:
USB-Serial TX ──[4.7kΩ]──┬── ATtiny412 PA0 (UPDI)
│
USB-Serial RX ────────────┘
| UPDI pin | Goes to |
|---|---|
| PA0 (UPDI) | Through 4.7kΩ → TX of USB-serial adapter |
| VCC | 5V from USB-serial adapter |
| GND | GND of USB-serial adapter |
In Arduino IDE: install megaTinyCore, select ATtiny412, set programmer to SerialUPDI, pick your COM port, hit upload.
UPDI only needs to be connected during programming — disconnect the programmer and the circuit runs on its own.
11. Full Wiring Diagram with UPDI Header¶
User: Yes (add UPDI header to diagram).
(Full wiring diagram generated including: 2x A1324 Hall sensors with 100nF decoupling caps, ATtiny412, 2x LEDs with 220Ω resistors, UPDI programming header with 4.7kΩ resistor, USB-serial adapter connection)
12. Using an Arduino Uno as UPDI Programmer¶
User: Can I use wire to connect another microcontroller to the ATtiny412 by having 2 headers leading to the PA0 pin, one with a 4.7k resistor?
Claude: Yes, that works. You absolutely need a shared ground — any time two circuits communicate they must share a common ground reference.
Voltage warning: The ESP32-C6 and RP2040 are both 3.3V devices with 5V-intolerant GPIO pins. Sending 5V directly into them can cause permanent damage. Options: 1. Run the ATtiny412 at 3.3V (but the A1324 requires 4.5V minimum — won't work) 2. Add a bidirectional level shifter (BSS138-based)
User: The ESP32. But if this is just for programming I can get an Arduino Uno.
Claude: Using an Arduino Uno is the simplest solution — it's a 5V device, no voltage concerns.
One gotcha: disable the Uno's onboard ATmega328P first. Best way: bridge the RESET pin to GND with a jumper wire. This holds the chip in reset so USB-serial passes straight through.
| Uno pin | ATtiny412 header |
|---|---|
| 5V | VCC |
| GND | GND |
| TX | UPDI (through 4.7kΩ) |
| RX | UPDI (through 4.7kΩ) |
| RESET | GND (jumper on Uno) |
13. Running the Program — End-to-End Workflow¶
User: What is the easiest way to run my program on the ATtiny412?
Claude: Easiest end-to-end workflow:
- Write code in Arduino IDE
- Plug Uno into PC via USB
- Connect Uno to ATtiny412 header with 4 wires + RESET jumper
- Hit Upload in Arduino IDE
- Unplug Uno from header
- Power the ATtiny412 circuit from any 5V source
Power options for final circuit (~40-50mA total draw):
| Power source | Notes |
|---|---|
| USB phone charger + micro USB breakout | Cheapest and easiest |
| 9V battery + 7805 regulator | Portable, regulated 5V |
| 5V USB power bank | Portable, no regulator needed |
| Bench power supply | Best for development/testing |
14. Selecting a 3V Hall Sensor for Coin Cell Operation¶
User: What Hall sensor works with 3V? So I could power it with a button battery.
Claude: Best 3.3V-compatible SMD options:
| Part | Package | Voltage | Notes |
|---|---|---|---|
| DRV5023A1QDBZR | SOT-23 | 2.5–38V | Very wide voltage range |
| AH1751 | SOT-23 | 1.65–3.6V | Designed for coin cells, ~10µA quiescent |
| SI7201-B | SOT-23 | 1.7–3.6V | Extremely low power |
Battery life estimate (CR2032, 220mAh):
| Mode | Current draw | Runtime |
|---|---|---|
| Always on | ~30mA | ~7 hours |
| Sleep between reads | ~0.1mA | Weeks–months |
Sleep mode on the ATtiny412 wakes on interrupt from the Hall sensor, does its thing, then goes back to sleep — highly recommended for coin cell use.
15. Redesign — Single Sensor, RGB LED, Self-Contained Node¶
User: I want to change my design so that each ATtiny412 only connects with 1 hall sensor and outputs to an RGB LED (possibly a small ring of RGB LEDs that all do the exact same action at the same time).
Claude: This significantly simplifies the design. For a single RGB LED or small ring where all LEDs do the same thing, a simple common cathode RGB LED works perfectly — just 3 PWM pins, no library, no data protocol.
| NeoPixel approach | Simple RGB approach | |
|---|---|---|
| Library needed | Yes | No |
| Wiring complexity | Medium | Very simple |
| Cost per node | Higher | Very low |
| Reliability | Good | Excellent |
Clean ATtiny412 pin assignment:
| Pin | Use |
|---|---|
| PA6 | Hall sensor input |
| PA1 | Red PWM |
| PA2 | Green PWM |
| PA3 | Blue PWM |
| PA0 | UPDI |
16. LED Behavior — Magnet Triggers Color Changes, Auto Off¶
User: I want my LEDs to have a simple program. Pass over them with a magnet, and they turn on. Pass again and they change color. After a few seconds without a magnet they turn off.
Choices made: - Colors: random - Timeout: 3 seconds - Turn off: fade out
#include <Arduino.h>
#define HALL_PIN PIN_PA6
#define RED_PIN PIN_PA1
#define GREEN_PIN PIN_PA2
#define BLUE_PIN PIN_PA3
const unsigned long TIMEOUT_MS = 3000;
const unsigned long DEBOUNCE_MS = 400;
struct Color { uint8_t r, g, b; };
Color randomColor() {
Color c;
switch (random(6)) {
case 0: c = {255, (uint8_t)random(50,200), 0}; break;
case 1: c = {255, 0, (uint8_t)random(50,200)}; break;
case 2: c = {0, 255, (uint8_t)random(50,200)}; break;
case 3: c = {(uint8_t)random(50,200), 255, 0}; break;
case 4: c = {0, (uint8_t)random(50,200), 255}; break;
default: c = {(uint8_t)random(50,200), 0, 255}; break;
}
return c;
}
void setColor(Color c, float brightness) {
analogWrite(RED_PIN, c.r * brightness);
analogWrite(GREEN_PIN, c.g * brightness);
analogWrite(BLUE_PIN, c.b * brightness);
}
Color current = {0, 0, 0};
float brightness = 0.0;
unsigned long lastTrigger = 0;
unsigned long lastDebounce = 0;
bool ledOn = false;
void setup() {
pinMode(HALL_PIN, INPUT_PULLUP);
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
randomSeed(analogRead(PIN_PA2));
}
void loop() {
bool magnet = !digitalRead(HALL_PIN);
unsigned long now = millis();
if (magnet && (now - lastDebounce > DEBOUNCE_MS)) {
lastDebounce = now;
lastTrigger = now;
current = randomColor();
ledOn = true;
}
if (ledOn) {
if (brightness < 1.0) {
brightness += 0.02;
brightness = min(brightness, 1.0f);
}
if (now - lastTrigger > TIMEOUT_MS) {
brightness -= 0.02;
if (brightness <= 0.0) {
brightness = 0.0;
ledOn = false;
}
}
setColor(current, brightness);
} else {
setColor({0,0,0}, 0);
}
delay(12);
}
For a small ring of RGB LEDs: wire all R pins together to PA1, all G to PA2, all B to PA3, all cathodes to GND. They behave identically with no code changes. Keep total current under 40mA per channel (~4 LEDs maximum per channel at full brightness with 100Ω resistors).
17. Final Node Wiring Diagram — Single Sensor, RGB LED, UPDI Header¶
(Final wiring diagram generated showing: DRV5023 Hall sensor with 100nF decoupling cap, ATtiny412, common cathode RGB LED with 100Ω resistors on R/G/B, UPDI programming header with 4.7kΩ resistor)
Pin summary: - PA6 = Hall sensor analog input - PA1 = Red PWM output - PA2 = Green PWM output - PA3 = Blue PWM output - PA0 = UPDI programming
18. Do 3 Pins Control RGB? — NeoPixel vs Simple RGB Explained¶
User: Do I need 3 pins to control RGB?
Claude: For a simple common cathode RGB LED — yes, 3 PWM pins, one per color. But this is straightforward and requires no library.
NeoPixel (WS2812B) uses 1 data pin but needs a library and has a built-in controller chip in each LED. For a small ring where all LEDs do the same thing, simple RGB is the better choice — cheaper, simpler, more reliable.
19. Cabinet Power System — USB Power Banks¶
User: Back to the power bank. Can I use the ATtiny412 to control the LEDs but have an additional power source for the LEDs? Like when using a motor?
Claude: Yes — this is standard practice, same as driving a motor. The ATtiny412 controls the signal, a separate power source handles the current.
Power bank 1 ── 5V ──► ATtiny412 + logic
Power bank 2 ── 5V ──► LED power
Both GNDs tied together ◄── critical
ATtiny412 data pin ──► LED signal
Recommended additions: - 300–500Ω resistor on data line between ATtiny412 and strip (protects against voltage spikes) - 1000µF capacitor across LED strip power and ground (smooths current spikes)
20. Power Bank Auto-Shutoff Warning¶
User: I am making a cabinet that will house one or more 5V power banks that will power multiple projects. (Movable cabinet.)
Claude: Power banks are ideal for a movable setup. Key consideration:
Auto-shutoff: Most power banks cut power after 30–60 seconds if they don't sense enough current (~50–100mA threshold). At ~40–50mA your circuit may be right on the edge. Solutions: - Buy "always on" or "low current mode" power banks (made for IoT) - Add a 100Ω 0.5W dummy load resistor across 5V and GND - Use Anker or similar brands that support low-current devices
Cabinet layout recommendations:
| Zone | What goes there |
|---|---|
| Power bay | Power bank(s) in a tray, easy to swap |
| Distribution rail | USB hub or 5V terminal block |
| Project slots | Each project in its own compartment |
| Programming port | Panel-mounted UPDI header on cabinet exterior |
For connectors: USB-A to bare wire cables, strip one end, wire to a terminal block — clean 5V and GND distribution point.
21. Choosing the Power Connector — PCB Fab Lab Footprints¶
User: (uploaded image: KiCad footprint browser showing PCM_fab library with options including Conn_PWRJack, MotorDriver, and Conn_USB_C_Socket_PowerOnly)
Image shows KiCad footprint browser with PCM_fab library containing: Conn_PWRJack_0.7x (barrel jack SMT), Conn_PWRJack_2x5 (barrel jack SMT), MotorDriver_TI_DRV8428EPWPR, MotorDriver_ThreePhase_AMT49400, Conn_USB_C_Socket_PowerOnly.
These are the footprints for power supply from the Fab Lab. Which one do I use to connect to my PCB? Why?
Claude: Use the Conn_USB_C_Socket_PowerOnly.
Reasons: - Your power banks output via USB — direct connection, no adapter needed - Designed exactly for 5V power delivery - Surface mount, reversible, modern and robust - PowerOnly means VBUS (5V) and GND only — exactly what you need
| Footprint | Why not |
|---|---|
| Barrel jack 0.7mm | For very small devices like earbuds |
| Barrel jack 2.0mm/5.5mm | For wall adapters, not USB power banks |
| MotorDriver_DRV8428 | Motor driver IC, not a power connector |
| MotorDriver_ThreePhase | Motor driver, not a power connector |
22. Understanding the USB-C Connector Pinout¶
User: (uploaded image: KiCad schematic and PCB footprint view of Conn_USB_C_Socket_GCT_USB4125-GF-A-0190 showing pins VBUS x2, GND x2, SHIELD, CC1, CC2)
Image shows the KiCad symbol with pins: VBUS (A9, B9), GND (A12, B12), SHIELD (S1), CC1 (A5), CC2 (B5). PCB footprint shown at bottom mounted at board edge.
Why are there 2 VBUS and 2 GND? What is SHIELD? What are CC1 and CC2?
Claude:
2x VBUS and 2x GND — duplicate power pins for current capacity. More pins = more copper contact = more current without overheating. Connect both VBUS pins to your 5V rail and both GND pins to your ground rail — they are electrically the same point.
SHIELD (S1) — the metal outer shell of the connector. Connect to GND to act as an EMI shield.
CC1 and CC2 (Configuration Channel) — these tell the power bank a device is plugged in and wants power. Without them the power bank may not turn on. For a power-only device pull both to GND through a 5.1kΩ resistor each:
CC1 ──[5.1kΩ]── GND
CC2 ──[5.1kΩ]── GND
This is mandatory — without these resistors many modern power banks will refuse to supply power.
23. Power Supply Filtering — Bulk and Decoupling Capacitors¶
User: Should I have a capacitor near the power supply to help with noise?
Claude: Yes — use two capacitors working together:
Bulk capacitor (100µF electrolytic): Handles large slow current surges — when LEDs suddenly turn on, this reservoir supplies the burst instantly. Place close to USB-C connector.
Decoupling capacitor (100nF ceramic): Handles fast high-frequency noise. Place right next to the bulk cap.
USB-C VBUS ──┬── 100µF electrolytic ──┬── to 5V rail
│ │
└── 100nF ceramic ────────┘
│
GND
Both in parallel between 5V and GND. Place as the very first thing after the USB-C connector on the 5V trace.
Important: The 100µF electrolytic is polarised — positive leg to 5V, negative leg (marked with stripe) to GND. Reversed installation will damage it.
Full power entry point components: USB-C connector + 2x CC resistors (5.1kΩ) + 100µF bulk cap + 100nF ceramic cap.
24. Decoupling Capacitor Placement — Parallel with Hall Sensor¶
User: Is the capacitor connected to the 5V and ground in parallel to the hall sensor?
Claude: Yes, exactly. The capacitor sits in parallel with the hall sensor's power pins — sharing the same VCC and GND connections:
5V ──┬── Hall sensor VCC
│
└── Cap positive leg
GND ──┬── Hall sensor GND
│
└── Cap negative leg
The capacitor is not in the signal path at all — it just sits across the power supply right next to the sensor. On a PCB this means placing the capacitor footprint right next to the sensor with short traces connecting their VCC and GND pads together.
End of design session transcript. Project status: single-node design finalized with ATtiny412, DRV5023 Hall sensor, common cathode RGB LED, UPDI programming header, USB-C power input with CC resistors and filtering capacitors.
25. System Integration Review — Improvements from Fab Academy Notes¶
Reference: https://fabacademy.org/2026/classes/system_integration/index.html
After reviewing the Fab Academy system integration class notes, the following improvements were identified and applied to the design.
Wiring failures addressed¶
Strain relief — USB-C connector The USB-C footprint has mechanical anchor pads (S1 shield pins) that must be soldered. These take physical stress from cable insertion/removal so the signal pads don't crack. Do not leave them unsoldered.
Polarized connectors — UPDI header The original 2.54mm pin header was replaced with a JST-PH keyed connector. JST-PH is physically keyed so it can only be inserted one way, preventing a reversed programming connection from damaging the ATtiny412.
Component failures addressed¶
GPIO current headroom — LED resistors increased Resistors increased from 100Ω to 150Ω on all three RGB channels. This reduces per-pin current from ~18mA to ~12mA, giving more margin below the ATtiny412's 20mA per-pin limit, especially when all three channels are active simultaneously.
Transient protection — TVS diode added A 5V clamping TVS diode is placed across VCC and GND at the power entry point, right after the USB-C connector. This clamps voltage spikes from the power bank before they can reach any other component.
Power failures addressed¶
Bulk capacitor — 100µF electrolytic added A 100µF electrolytic capacitor is placed at the power entry point to handle large current surges when LEDs change state. Note: this is polarised — positive leg to 5V, negative leg (stripe) to GND.
Local MCU decoupling cap — 100nF added at ATtiny412 A dedicated 100nF ceramic capacitor is placed between the ATtiny412's VCC and GND pins, physically close to the chip on the PCB. This is separate from the power entry filter cap and handles high-frequency noise local to the processor, preventing transient faults.
CC resistors — USB-C power negotiation Two 5.1kΩ resistors connect CC1 and CC2 to GND. This signals to the USB power bank that a valid device is connected, preventing the bank from withholding power.
Ground plane On the PCB, use a solid ground plane on the back copper layer rather than individual ground traces. This prevents ground loops and provides a low-impedance reference for all components.
Updated full component list (BOM additions)¶
| Component | Value | Qty | Purpose |
|---|---|---|---|
| TVS diode | 5V clamp (e.g. SMBJ5.0A) | 1 | Transient protection at power input |
| Electrolytic cap | 100µF, 10V+ | 1 | Bulk power reservoir |
| Ceramic cap | 100nF, 0603 | 3 | 1x power filter, 1x MCU local, 1x hall sensor |
| Resistor | 5.1kΩ | 2 | USB-C CC1 and CC2 pull-down |
| Resistor | 150Ω | 3 | RGB LED current limiting (R, G, B) |
| Resistor | 4.7kΩ | 1 | UPDI data line |
| JST-PH connector | 3-pin keyed | 1 | UPDI programming header |
| Hall sensor | DRV5023 SOT-23 | 1 | Magnetic detection |
| RGB LED | Common cathode | 1+ | Output (ring wired in parallel) |
| ATtiny412 | SOIC-8 | 1 | Microcontroller |
| USB-C connector | GCT USB4125 PowerOnly | 1 | Power input |
Repair and modularity notes¶
Per the Fab Academy notes on repairability: - The LED and PCB should be separable via a JST connector so a failed LED can be replaced without replacing the whole board - The node is self-contained and modular — one unit can be removed from the cabinet without affecting others - Programming header is external-facing so code can be updated without disassembly
Document updated after Fab Academy system integration class review, May 2026.
26. Component Update — TVS Diode Replaced with 5.1V Zener SOD123¶
After reviewing the available components in the Fab Lab KiCad library (PCM_fab), no TVS diode footprint was available. The library contains the following diode options:
- Diode_Schottky_0603
- Diode_Schottky_MiniSMA
- Diode_Schottky_SOD123
- Diode_Zener_SOD123
Schottky diodes are not suitable for voltage clamping. The Diode_Zener_SOD123 was selected as the substitute.
TVS vs Zener for this application:
| Property | TVS diode | 5.1V Zener SOD123 |
|---|---|---|
| Purpose | Transient suppression | Voltage clamping |
| Transient energy handling | Very high (400W+) | Lower (~500mW) |
| Response time | Very fast | Fast |
| Suitable for USB power bank | Yes | Yes — low spike risk source |
| Available in fab library | No | Yes |
For a USB power bank source — which is already regulated and low-risk for large transient spikes — a 5.1V Zener in SOD123 is adequate protection.
Wiring: Cathode to 5V rail, anode to GND. Placed immediately after the USB-C connector before any other components.
Suggested part: BZX84C5V1 or MMSZ5231B — both are 5.1V Zener in SOD123 package.
Also noted from fab library — available RGB LED footprint:
The LED_RGB_CreeLED_PLCC4 footprint (LED RGB 4PLCC SMD) is available in the fab library and replaces the generic RGB LED placeholder in the schematic.
Hall sensor note:
The fab library contains Sensor_HallEffect_DiodesInc_AH49EN (SENSOR HALL ANALOG SOT23-3). This is an analog Hall sensor similar in operation to the A1324 used in this design. The existing analog threshold code is compatible with this sensor.
Updated BOM to reflect fab library component availability, May 2026.
27. Correction — Hall Sensor Confirmed as A1324LLHLT-T¶
An earlier section incorrectly substituted the AH49EN from the fab library. The correct sensor throughout this design is the Allegro A1324LLHLT-T, which is what was purchased and is already placed in the schematic.
KiCad schematic fields confirmed:
| Field | Value |
|---|---|
| Reference | U1 |
| Value | Sensor_HallEffect_Analog_A1324LLHLT-T |
| Footprint | PCM_fab:SOT-23-3 |
| Datasheet | https://www.allegromicro.com/~/media/Files/Datasheets/A1324-5-6-Datasheet.ashx |
| Description | SENSOR HALL EFFECT ANALOG SOT23W |
Key notes:
- The footprint PCM_fab:SOT-23-3 is the fab library's name for the SOT-23W package — no external footprint import needed
- The A1324 is an analog output sensor requiring 4.5–5.5V supply — the 5V circuit design is correct
- The analog threshold code using analogRead() and a deviation from the 512 quiescent midpoint is correct for this sensor
- No code changes required
Correction logged May 2026.