The code for controlling the regulator via the potentiometer is also inside this loop. If we want to turn off the valve instead, we would use digitalWrite(valvePin, LOW). For example, we can open the valve using the code in line 4: by using the digitalWrite() function to set the digital pin that controls the valve (via the relays) to HIGH, we turn on the valve. Most of the functionality of the program is contained in this loop. In line 15 below, we have delay(1000), so the loop will repeat every 1 second. This function essentially pauses the program for X milliseconds before continuing. However, unlike setup(), this function repeats continuously, with the speed at which it repeats determined by the delay() function. Next is the loop() function, which is also required for all Arduino programs. We also set the digital pins connected to the valve and regulator to behave as output pins.
Here, we initialize serial communications at 9600 bits per second (baud) between the microcontroller and the computer. The setup function will only run once after a sketch starts, following each powerup or reset of the Arduino. Next is the setup() function, which is required for all Arduino programs.
We also create the variables flowReading and potValue to store the values that the Arduino reads from the flow sensor and potentiometer. We use one of these pins, Pin 9, to control the regulator. The Arduino has 6 pins capable of pulse-width modulation (PWM), which are marked by a ~ next to the pin number. Pins 0 and 1 cannot be used because we are also using serial communications, so we use Pin 2 for the valve.įor the regulator, we need a continuous control signal, unlike the valve which only requires a binary on/off signal. There are 14 numbered digital pins on the Arduino Uno. The analog pins are input only, so we need to use the digital pins. The valve (via the relays) and the pressure regulator are controlled by output signals from the Arduino. The flow sensor and potentiometer output analog voltages, so we connect them to the analog input pins A0 and A3, as seen in the wiring diagram in the assembly instructions.
By using these variables, we don't have to update numbers throughout the code every time we change the wiring. Otherwise, read the brief tutorial below about basic Arduino coding.įirst, we define some variables to assign and help keep track of what the various pins are connected to. Those already familiar with Arduino programming can use and customize this sample code for monitoring the sensors and controlling the valves. If you were able to get the guide's Blink example to work, you're ready to write and upload your own custom code to control the board hardware. If you haven't done so already, set up your Arduino Uno microcontroller using the official setup guide: Windows / Mac Try making it go through its entire range of motion. Connect an actuator and turn the potentiometer dial to control how much pressure it receives.If you have the valves correctly open, you should be able to feel air coming out of the control board's output hose. The behavior may be a little counter-intuitive since these solenoid valves are the "normally closed" model, which only open when they are powered.
This is a high tech, moulded, low cost manufactured from high impact polycarbonate.
The Key Instruments MR3000 series variable area flow meter measures the gas flow rate of 0.4L/min to 5L/min. Product Details Key Instruments Flow Meter