ATtiny212 Firmware for Distortion Pedal

Please analyze this schematic carefully. The relay coil now works and K2 clicks, but the distortion effect does not work when the relay switches to the NO / effect position.
The project is a guitar distortion pedal with relay bypass.
Important context:
  • U2 is ATtiny212.
  • PA1 drives Q2 relay driver.
  • K2 is Omron G6S-2F 5VDC relay.
  • D2 flyback diode was found reversed during testing and was temporarily removed. Please verify its correct orientation.
  • Relay coil works now, but when the relay switches, the distortion path does not produce sound.
  • I need you to check whether the schematic routing is correct, especially the relay audio contacts, VREF, analog power, and mute/photorelay circuit.
Please analyze these points:
  1. Relay K2 audio routing: Check the exact relay pinout and footprint for Omron G6S-2F 5VDC. Verify if the relay contacts are connected correctly.
For bypass / relay OFF:
  • JACK_IN_TIP should connect to BYPASS_LINK.
  • JACK_OUT_TIP should connect to BYPASS_LINK.
  • The signal should bypass the distortion circuit.
For effect ON / relay energized:
  • JACK_IN_TIP should connect to EFFECT_IN.
  • EFFECT_OUT should connect to JACK_OUT_TIP.
  • BYPASS_LINK should be disconnected from the active audio path.
Please explicitly tell me:
  • In relay OFF state, which nets are connected?
  • In relay ON state, which nets are connected?
  • Is COM/NC/NO mapping correct for this relay footprint?
  • Is the footprint possibly mirrored or using bottom-view pin numbering incorrectly?
  1. D2 flyback diode: Verify D2 orientation. Correct expected orientation:
  • D2 cathode / stripe side should connect to +5V / relay coil positive.
  • D2 anode should connect to RELAY_COIL_NEG / Q2 collector / relay coil negative. If D2 is reversed, explain what happens and confirm how it should be installed.
  1. Q2 relay driver: Confirm that Q2 is wired correctly:
  • PA1 → R4 → Q2 base.
  • R5 pulls base to GND.
  • Q2 emitter goes to DGND.
  • Q2 collector goes to RELAY_COIL_NEG. Expected ON state:
  • PA1 = 5V.
  • Q2 base = about 0.6–0.8V.
  • Q2 collector / RELAY_COIL_NEG = about 0–0.6V.
  • Relay coil has about 4.5–5V across it.
  1. U4 photorelay / mute circuit: Please analyze U4 carefully. It appears connected around EFFECT_OUT and GND/DGND. Check if U4 can mute or short EFFECT_OUT to ground. Tell me:
  • Is U4 intended as anti-pop mute?
  • Should U4 be ON only briefly during relay switching?
  • Should U4 be OFF during normal effect ON operation?
  • If PA6 keeps U4 ON, could it completely mute the distortion output?
  • What should PA6 logic be during bypass, switching, and effect ON?
  1. VREF and analog power: Check the analog section. Verify:
  • +9V_CLEAN reaches the op-amps.
  • VREF is generated correctly by R9/R10 and capacitors.
  • VREF should be approximately half of +9V_CLEAN, around 4–4.5V.
  • All op-amp reference inputs that need VREF are connected.
  • No op-amp input is floating.
  • The analog ground and digital ground are connected correctly.
  1. Distortion signal path: Trace the full effect signal path and confirm it is complete:
  • EFFECT_IN
  • input buffer
  • BUFFER_OUT
  • gain / clipping stage
  • DRIVE_OUT
  • tone section
  • volume/output section
  • EFFECT_OUT
  • relay output to JACK_OUT_TIP
Please identify any possible missing connection, wrong net label, floating node, or incorrect capacitor/potentiometer wiring that would make the distortion path silent.
  1. Potentiometers: Check the gain, tone, and volume potentiometer connections. Make sure:
  • wipers are connected to the correct nets.
  • end terminals are not swapped in a way that shorts signal to ground.
  • volume output actually reaches EFFECT_OUT.
  1. Clipping diodes: Check D3/D4 clipping diodes. Verify they are connected to the correct gain stage nodes and not accidentally shorting the signal.
  2. Provide a measurement checklist: Give me a step-by-step list of what to measure with a multimeter:
  • +9V_CLEAN to GND
  • VREF to GND
  • EFFECT_OUT to GND resistance with power off
  • JACK_IN_TIP to EFFECT_IN continuity in relay ON
  • JACK_OUT_TIP to EFFECT_OUT continuity in relay ON
  • JACK_IN_TIP to BYPASS_LINK continuity in relay OFF
  • JACK_OUT_TIP to BYPASS_LINK continuity in relay OFF
  • PA6 state and whether U4 is muting
  1. Provide a likely fault list: Based on the schematic, list the most likely reasons why the relay switches but the distortion does not work.
Do not write firmware yet. First analyze the schematic and give me:
  1. Relay routing truth table.
  2. VREF/power verification.
  3. U4 mute analysis.
  4. Possible schematic/footprint mistakes.
  5. Measurement checklist.

7:25

Thought for 17 sec

Read K2 datasheet for pin configuration contact arrangement te.

Read U4 datasheet for pin configuration input output photorela.

Read U2 datasheet for pinout pin configuration ATtiny212 SOIC .

Read BOM.

Read schematic.

Read schematic.

Read schematic.

Read schematic.

Read schematic.

Found 1 results for Omron G6S-2F-DC5 datasheet pinout COM NC NO pins 3 4 5 8 9 10 bottom view.

Completed 3 design checks — found 141 issues.

I found two high-probability causes: K2’s COM/NC pin mapping in the schematic appears inconsistent with the Omron G6S-2F pinout, and U4 can mute EFFECT_OUT if PA6 is held HIGH. D2’s schematic orientation is correct: cathode/stripe to +5V, anode to RELAY_COIL_NEG.
Full relay truth table, VREF/power review, U4 mute logic, fault list, and measurement checklist are in Relay Distortion Path Debug Analysis.
Fix K2 mapping
Corrected relay table
Trace effect path
Check U4 mute
Run ERC/DRC

Refine this doc
Ask about this doc
Firmware Starter — ATtiny212 Relay Bypass Pedal
Platform & Toolchain
  • MCU: U2 — Microchip ATTINY212-SSN
  • Framework: Arduino IDE with megaTinyCore
  • Clock: Internal oscillator; choose a normal megaTinyCore ATtiny212 board configuration for your hardware.
  • Programmer: UPDI via the schematic's PA0/UPDI connection.
  • Libraries: None beyond the Arduino core.

Schematic-Derived Pin Mapping


FunctionSchematic signal pathATtiny212 pinArduino / megaTinyCore symbolDirectionActive levelNotes
Footswitch inputFOOT_SW_NODE → U2 PA3physical pin 7PIN_PA3InputActive LOWAssumes the footswitch shorts this node to GND when pressed. Firmware enables internal pull-up.
Relay driver controlU2 PA1 → R4 4.7 kΩ → Q2 BASE; Q2 COLLECTOR → relay coil negative node / RELAY_COIL_NEGphysical pin 4PIN_PA1OutputActive HIGH at PA1PA1 HIGH drives Q2 on, pulling RELAY_COIL_NEG low and energizing the relay coil. PA1 LOW leaves relay off.
LED indicatorU2 PA2 → D1 pin 1; D1 pin 2 → R2 2.2 kΩ → +5Vphysical pin 5PIN_PA2OutputActive LOWLED appears wired from +5 V through R2/D1 into the MCU pin, so the MCU sinks current to turn it on. If the LED is physically reversed, change LED_ACTIVE_LEVEL to HIGH.
Anti-pop photorelay inputU2 PA6 → R3 1.2 kΩ → U4 Aphysical pin 2PIN_PA6OutputNot used by requested functionLeft off by this firmware unless you choose to add mute timing later.
UPDI / resetU2 ~RESET~/PA0 → PA0/UPDI header/netphysical pin 6PIN_PA0Programming / resetN/ADo not use as a normal GPIO unless you intentionally disable UPDI/reset behavior.
PowerU2 VCC+5V; U2 GNDGNDpins 1, 8N/APowerN/ALogic supply is +5 V.
Behavior Implemented
  • Power-up default: bypass / effect OFF / relay OFF.
  • Every valid footswitch press toggles the effect state once.
  • Holding the footswitch does not repeatedly toggle.
  • Debounce time: 40 ms, within the requested 30–50 ms range.
  • Relay output follows effect state: effect ON energizes the relay; effect OFF de-energizes it.
  • LED follows effect state using active-low drive based on the schematic.
Arduino IDE Setup
  1. Install megaTinyCore in Arduino IDE.
  2. Select an ATtiny412/212-series board target and choose ATtiny212 as the chip.
  3. Select the appropriate clock option for your board.
  4. Upload using a UPDI programmer connected to PA0/UPDI, VCC, and GND.
Complete Firmware Source
Save as distortion_relay_bypass_attiny212.ino:

Cpp


/*
  Distortion Effect Pedal Relay Bypass Firmware
  MCU: ATtiny212 (U2, ATTINY212-SSN)
  Core: Arduino IDE + megaTinyCore

  Schematic-derived connections:
    FOOT_SW_NODE       -> U2 PA3, physical pin 7, active LOW input with pull-up
    Relay driver input -> U2 PA1 through R4 to Q2 base
    RELAY_COIL_NEG     -> Q2 collector / relay coil negative, pulled LOW when Q2 is ON
    LED indicator      -> U2 PA2 to D1, with R2 to +5V; assumed active LOW

  Power-up state:
    Effect OFF / bypass / relay OFF / LED OFF
*/

#include <Arduino.h>

// ─── Pin Definitions — from schematic ─────────────────────────────
constexpr uint8_t FOOTSWITCH_PIN = PIN_PA3;   // U2 PA3, physical pin 7, FOOT_SW_NODE
constexpr uint8_t RELAY_DRIVE_PIN = PIN_PA1;  // U2 PA1, physical pin 4, drives Q2 base via R4
constexpr uint8_t LED_PIN = PIN_PA2;          // U2 PA2, physical pin 5, D1 indicator LED
constexpr uint8_t MUTE_PHOTORELAY_PIN = PIN_PA6; // U2 PA6, physical pin 2, U4 input via R3; unused here

// ─── Active Levels ────────────────────────────────────────────────
constexpr uint8_t FOOTSWITCH_PRESSED_LEVEL = LOW;  // switch assumed to pull FOOT_SW_NODE to GND
constexpr uint8_t RELAY_ON_LEVEL = HIGH;           // PA1 HIGH turns Q2 on and energizes relay
constexpr uint8_t RELAY_OFF_LEVEL = LOW;

// LED appears connected from +5V through R2/D1 into PA2, so PA2 sinks current when LOW.
constexpr uint8_t LED_ACTIVE_LEVEL = LOW;
constexpr uint8_t LED_INACTIVE_LEVEL = HIGH;

// Optional anti-pop photorelay is left off. Adjust if you later add mute timing.
constexpr uint8_t MUTE_INACTIVE_LEVEL = LOW;

// ─── Debounce Configuration ───────────────────────────────────────
constexpr unsigned long DEBOUNCE_TIME_MS = 40;  // requested 30–50 ms range

// ─── State Variables ──────────────────────────────────────────────
bool effectOn = false;

uint8_t lastRawFootswitchLevel = HIGH;
uint8_t debouncedFootswitchLevel = HIGH;
unsigned long lastDebounceChangeMs = 0;

// ─── Output Helpers ───────────────────────────────────────────────
void applyEffectState()
{
  if (effectOn) {
    // Effect ON: energize relay so audio path switches to distortion circuit.
    digitalWrite(RELAY_DRIVE_PIN, RELAY_ON_LEVEL);
    digitalWrite(LED_PIN, LED_ACTIVE_LEVEL);
  } else {
    // Effect OFF: relay off, bypass mode.
    digitalWrite(RELAY_DRIVE_PIN, RELAY_OFF_LEVEL);
    digitalWrite(LED_PIN, LED_INACTIVE_LEVEL);
  }
}

void setDefaultBypassState()
{
  effectOn = false;
  applyEffectState();
}

// ─── Setup ────────────────────────────────────────────────────────
void setup()
{
  // Configure outputs first and force safe defaults before enabling input logic.
  pinMode(RELAY_DRIVE_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);
  pinMode(MUTE_PHOTORELAY_PIN, OUTPUT);

  digitalWrite(MUTE_PHOTORELAY_PIN, MUTE_INACTIVE_LEVEL);
  setDefaultBypassState();

  // Footswitch input uses internal pull-up because the switch is assumed to pull to GND.
  pinMode(FOOTSWITCH_PIN, INPUT_PULLUP);

  // Initialize debounce state from the current input level.
  lastRawFootswitchLevel = digitalRead(FOOTSWITCH_PIN);
  debouncedFootswitchLevel = lastRawFootswitchLevel;
  lastDebounceChangeMs = millis();
}

// ─── Main Loop ────────────────────────────────────────────────────
void loop()
{
  const unsigned long nowMs = millis();
  const uint8_t rawLevel = digitalRead(FOOTSWITCH_PIN);

  // If the raw input changed, restart debounce timing.
  if (rawLevel != lastRawFootswitchLevel) {
    lastRawFootswitchLevel = rawLevel;
    lastDebounceChangeMs = nowMs;
  }

  // Accept a new stable input state after debounce time has elapsed.
  if ((nowMs - lastDebounceChangeMs) >= DEBOUNCE_TIME_MS &&
      rawLevel != debouncedFootswitchLevel) {

    debouncedFootswitchLevel = rawLevel;

    // Toggle only on the transition to the pressed state.
    // This prevents repeated toggles while the switch is held.
    if (debouncedFootswitchLevel == FOOTSWITCH_PRESSED_LEVEL) {
      effectOn = !effectOn;
      applyEffectState();
    }
  }
}
Notes / Verification Points
  • The schematic shows FOOT_SW_NODE at U2 PA3, but only firmware-level behavior can confirm the external footswitch polarity. If the switch does not pull to ground, change pinMode(FOOTSWITCH_PIN, INPUT_PULLUP) and FOOTSWITCH_PRESSED_LEVEL accordingly.
  • RELAY_COIL_NEG is not directly driven by U2; it is the relay coil low-side node at Q2 collector. U2 drives Q2 through PA1/R4, so the correct firmware output is PA1, active HIGH.
  • The LED is inferred as active LOW because R2 goes to +5V and D1 then connects to PA2. If testing shows inverted LED behavior, swap LED_ACTIVE_LEVEL and LED_INACTIVE_LEVEL.
  • PA6 appears to drive the TLP3431 anti-pop photorelay input through R3. The requested firmware does not sequence mute timing, so it is held inactive.

    Platform & Toolchain

    Schematic-Derived Pin Mapping

    Behavior Implemented

    Arduino IDE Setup

    Complete Firmware Source

    Notes / Verification Points

Documents

    Firmware Starter — ATtiny212 Relay Bypass Pedal

    Relay Distortion Path Debug Analysis

Assets

imageDistor.png

imageDistor.png

imageDistor
Gitar.png

Gitar.png

GitarThumbnail
155467.svg

155467.svg

155467
spike-design-guitar-svgrepo-com 222.svg

spike-design-guitar-svgrepo-com 222.svg

spike-design-guitar-svgrepo-com 222
Flux.svg

Flux.svg

Flux
image-removebg-preview (1).svg

image-removebg-preview (1).svg

image-removebg-preview (1)

Modern Distortion effect pedal V1

Modern Distortion effect pedal V1 thumbnail
Modernlow-noise distortion effect pedal for electric guitar. This pedal provides adjustable gain, tone, and volume control with relay true bypass and soft-touch footswitch operation. The design includes LED status indication, anti-pop mute switching, reverse polarity protection, and separated analog and digital power sections for improved stability and reduced noise. The project uses an ATtiny412 tinyAVR 1-series microcontroller for control logic, a TPS70950 voltage regulator for the digital supply, OPA1656 audio op-amps for the analog signal path, a G6K-2F-Y-DC5 relay for bypass switching, a TLP3431 photorelay for anti-pop mute control, and BAS16 diodes for symmetrical clipping.

Properties

Properties describe core aspects of the project.

Pricing & Availability

Distributor

Qty 1

Arrow

$7.95–$10.74

Digi-Key

$8.31–$11.00

HQonline

$4.92–$4.95

LCSC

$14.45–$14.49

Mouser

$26.32

TME

$12.72

Verical

$1.21–$22.37

Controls