Make your own spot welder using a microwave transformer, a HUGE triac and an Arduino. Control the spot pulse and more
by: ELECTRONOOBS on 2026-08-07

//More on https://electronoobs.com/ SUBSCRIBE! Thanks <3
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED Display Configuration
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// Hardware Pin Definitions (Check scheamtic)
const int TRIAC_PIN = 9; // Output to the MOC3052 optocoupler input
const int PEDAL_PIN = 8; // Foot switch input (INPUT_PULLUP)
const int BTN_UP = 2; // Menu Button Up / Safety Toggle
const int BTN_DOWN = 4; // Menu Button Down
const int BUZZER_PIN = 5; // Piezo buzzer pin for audio feedback
const int POT_PULSE_1 = A0; // Potentiometer 1: Pre-weld pulse duration
const int POT_PULSE_2 = A1; // Potentiometer 2: Main weld pulse duration
// Variables for Weld Timings
int pulse1_ms = 15;
int pulse2_ms = 60;
const unsigned long PAUSE_BETWEEN_PULSES = 40; // 40ms settling gap
// Safety and System States
bool systemArmed = false; // System starts in SAFE mode
bool welding = false;
unsigned long lastButtonPress = 0;
void setup() {
pinMode(TRIAC_PIN, OUTPUT);
pinMode(PEDAL_PIN, INPUT_PULLUP);
pinMode(BTN_UP, INPUT_PULLUP);
pinMode(BTN_DOWN, INPUT_PULLUP);
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(TRIAC_PIN, LOW); // Force TRIAC off at boot
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
for(;;); // Halt if screen fails
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
// System start beep
tone(BUZZER_PIN, 1800, 150);
}
void loop() {
readPotentiometersWithFilter();
handleButtons();
checkPedal();
updateDisplay();
}
// Software smoothing filter to prevent potentiometer value jumping/jittering
void readPotentiometersWithFilter() {
int raw1 = analogRead(POT_PULSE_1);
int targetPulse1 = map(raw1, 0, 1023, 0, 60); // 0ms (OFF) to 60ms
// Only update value if knob moves by more than 1ms (filters out minor noise)
if (abs(targetPulse1 - pulse1_ms) > 1 || targetPulse1 == 0) {
pulse1_ms = targetPulse1;
}
int raw2 = analogRead(POT_PULSE_2);
int targetPulse2 = map(raw2, 0, 1023, 15, 300); // 15ms to 300ms
if (abs(targetPulse2 - pulse2_ms) > 2) {
pulse2_ms = targetPulse2;
}
}
void handleButtons() {
// Use UP Button to toggle Armed/Safe mode for security
if (digitalRead(BTN_UP) == LOW) {
if (millis() - lastButtonPress > 300) {
systemArmed = !systemArmed;
if (systemArmed) {
tone(BUZZER_PIN, 2800, 150); // High pitch double beep for ARMED
delay(100);
tone(BUZZER_PIN, 2800, 150);
} else {
tone(BUZZER_PIN, 1200, 300); // Low long pitch tone for SAFE
}
lastButtonPress = millis();
}
}
// Down button reserved for future menu expansions (like a counter reset)
if (digitalRead(BTN_DOWN) == LOW) {
if (millis() - lastButtonPress > 300) {
tone(BUZZER_PIN, 2000, 30); // Short click
lastButtonPress = millis();
}
}
}
void checkPedal() {
if (digitalRead(PEDAL_PIN) == LOW && !welding) {
// Only fire if the system has been explicitly armed via the button
if (systemArmed) {
executeWeldSequence();
} else {
// Alert user they forgot to arm the system
tone(BUZZER_PIN, 800, 200);
delay(300);
}
}
}
void executeWeldSequence() {
welding = true;
// Pre-weld count-down tone
tone(BUZZER_PIN, 2500, 80);
delay(200);
// --- PULSE 1 (Fires only if potentiometer is turned past 0) ---
if (pulse1_ms > 0) {
digitalWrite(TRIAC_PIN, HIGH);
delay(pulse1_ms);
digitalWrite(TRIAC_PIN, LOW);
delay(PAUSE_BETWEEN_PULSES); // Settlement window
}
// --- PULSE 2 (Main Weld) ---
digitalWrite(TRIAC_PIN, HIGH);
delay(pulse2_ms);
digitalWrite(TRIAC_PIN, LOW);
// Fire confirmation tone
tone(BUZZER_PIN, 1500, 100);
// Safety Lockout: Hold program until pedal is fully released
while(digitalRead(PEDAL_PIN) == LOW) {
delay(10);
}
delay(500); // Thermal cooling delay
welding = false;
}
void updateDisplay() {
display.clearDisplay();
// Status Bar
display.setCursor(0, 0);
if (systemArmed) {
display.print("STATUS: ** ARMED **");
} else {
display.print("STATUS: LOCKED ");
}
display.drawFastHLine(0, 11, 128, SSD1306_WHITE);
// Potentiometer 1 Readout
display.setCursor(0, 22);
display.print("P1 Pre-Weld: ");
if (pulse1_ms == 0) {
display.print("OFF");
} else {
display.print(pulse1_ms);
display.print(" ms");
}
// Potentiometer 2 Readout
display.setCursor(0, 42);
display.print("P2 MainWeld: ");
display.print(pulse2_ms);
display.print(" ms");
// Quick Menu Hint
display.setCursor(0, 56);
display.setTextSize(0);
display.print("Press UP to Lock/Arm");
display.setTextSize(1);
display.display();
}
Leave a comment
Please login in order to comment.