My first sketch, would this work? It seems too easy...


I have fixed up an old MIG welder and it works again, but the gas flow is uninterupted (I need to close the valve on the bottle to stop the flow). So I will fit an electric valve and this gives me the opportunity to add some functions. What I want is the gas to flow before the wire feed starts and the wire feed to stop before the gas flow does.

I have done some Arduino project, but I've always copied other people's handywork. Here is my first ever sketch. Would this work? It seems almost too easy...

* This sktech is used to switch on the wire feed of my MIG welder a little later then the gas flow starts, and to keep the gas flowing a bit longer after the wire feed is stopped

 // declaring the pins:
 int WireFeed = 4;
 int GasFlow = 6;
 int Switch = 8;

void setup() {
 // define in and out puts:
 pinMode(WireFeed, OUTPUT);
 pinMode(GasFlow, OUTPUT);
 pinMode(Switch, INPUT);
 // set everything low to start with:
 digitalWrite(WireFeed, LOW);
 digitalWrite(GasFlow, LOW);

void loop() {

 // Turning on the gas flow before the wire feed:
if (digitalRead(Switch) == HIGH && digitalRead(GasFlow) == LOW && digitalRead(WireFeed) == LOW)
 digitalWrite(GasFlow, HIGH);
 digitalWrite(WireFeed, HIGH);

 // Leaving the gas flow on a bit after cutting the wire feed:
if (digitalRead(Switch) == LOW && digitalRead(GasFlow) == HIGH && digitalRead(WireFeed) == HIGH)
 digitalWrite(WireFeed, LOW);
 digitalWrite(GasFlow, LOW);


No it won't work because it's not posted properly in code tags!

Seriously though, without seeing a wiring hookup and any knowledge of the sensors/switches, who can say. The logic, as you've said, is pretty basic as long as you think starting the gas flow only 750ms before the wire feed is enough time.

Another thought that needs consideration, you're testing three state variables with two tests. The possible combinations of three state variables is six. You really ought to have declared plans to address those other four rather than just let them fall through the cracks. Have a look at the various write-ups on state machines.

Would this work? It seems almost too easy...

"Too easy" is what the Arduino system is all about :slight_smile:

And a key part of that is that it is so easy to try a program to see if it works. If it does not work then tell us exactly what happens and we will try to help you fix it.


I kust remembered I still have an old board and test kit.

Next I will replace the leds with buz11 mosfets and some resistors and I need a stable power source as the incoming voltage varies from 25 to 31V.


Hi Hugo,

Here are some good voltage regulators to achieve stable 5 volts from a source like you described.