Introduction: Arduino Controlled SIP & PUFF Switch

The Arduino series of micro-controllers opens up a huge world of possibilities for novice programmers and hobbyists! With freely available development systems and tutorials, and a vast array of library functions and sample sketches, just about anyone can succeed in designing and building projects that once would have required an advanced degree in electronics and programming.

When I set out to develop my SIP&PUFF controlled kayak, the subject of another Instructable, I discovered that commercially available SIP&PUFF switches were very costly, and thus prohibitive for many hobbyists to experiment with in their designs.

This Instructable will fully detail how to construct a u-contoller based SIP&PUFF switch with the minimum and least expensive hardware I know of. I'll present complete purchasing info and detail how to fabricate a few parts you may wish to make yourself.

Step 1: PARTS LIST

1. 1EA Arduino microController - I love the outdated Duemilinove, but you can use just about ANY of the available models for this rather simple project. I bought mine from www.SparkFun.com for approximately $34.

2. 2EA DesignFlex PSF102 Series Pressure/Vacuum Switches, Part Number: 7882-700. Visit their web site for details: www.designflexswitches.com/switches/psf102.php. I purchased my switches through www.Globalepower.com ((847) 965-9808) for about $18 each.

3. Several Feet 1/16" ID X 3/16" OD Tygon Tubing, available from McMaster-Carr (www.McMaster.com) under their Part Number: 5466K31, for $1.09 per foot.

4. 4EA 1/16" X 10-32 Barbed Tube Fittings, available from McMaster-Carr under their Part Number: 2974K123, for $4.21 per package of 10.

5. 1EA 3/8" X 2-1/4" Polycarbonate Rod, or equivalent, for the Mouthpiece. Look at McMaster-Carr's Part Number 8571K13 at $1.82 per foot.

6. 1EA .65" X .50" X .25" Polycarbonate/Acrylic/Plastic/Delrin/Brass (your choice) small block to make the "Y" Manifold from. Even Easier - Purchase this part from McMaster-Carr with their Part Number: 2974K391, but you'll buy a package of 10 for $7.10.

Step 2: THE PRESSURE/VACUUM SWITCHES

Utilizing the DesignFlex PSF102 Series Pressure/Vacuum Switches, Part# 7882-700, is as simple as choosing the HIGH (Pressure) Port on one and the Low (Vacuum) Port on the other.

Connect one of the terminals from each switch together and then to Ground (for Negative Logic). From the switch of which you are using the High Port, connect the other terminal to the PUFFinput pin of the uController. From the switch of which you are using the Low Port, connect the other terminal to the SIPinput pin of the uController.

In the completed assembly, Sipping on the Mouthpiece will Ground the SIPinput pin of the uController, and Puffing (blowing lightly) into the Mouthpiece will Ground the PUFFinput pin of the uController.

Step 3: THE Y (SPLITTER) MANIFOLD

If you care to make your "Y" Manifold, the photos attached to this step should give you all the info you need. Note how the .159 holes (for 10-32 thread) drilled in from opposite sides interfere with each other slightly, creating an open air passage between all the holes.

After drilling the holes, tap them with a 10-32 Bottoming Tap. Use a small sliver of Plumbers' Tape when you install the 1/16 X 10-32 Barbed Tube Fittings.

Alternatively, purchase a completed "Y" Adapter from McMaster-Carr (www.McMaster.com) with their Part Number: 2974K391. You'll get a package of 10 for $7.10.

In case it's not clear, the two holes on one side are at 0.145" centers. That leaves enough room for the barbed fittings to be tightened into place. Holes for 10-32 are 0.159"

Step 4: THE MOUTHPIECE

The Mouthpiece may be the only part of this design you actually need to fabricate yourself. I am sure there are other solutions out there, but I haven't found them and this will fit the 1/16 X 10-32 Barbed Tube Fitting utilized in this design.

Use just about any solid plastic type material for this part: Polycarbonate, Acrylic, Delrin, etc.

Start with a rod of approximately 3/8" Diameter and 2-1/4" in length. Put the rod in a lathe and drill a 0.159 hole all the way through it. Later, you will tap the one end with a 10-32 Bottoming Tap for the Barbed Fitting.

Cut some smooth grooves near the mouth end of the tube to enable the user to grip it with their lips and teeth. Polish it up while still in the lathe with scouring pad material to remove all roughness and sharp edges.

Step 5: THE SCHEMATIC AND CODE

I have included a portion of the Arduino Duemilinove schematic to illustrate the connections I used for my project. You can use any of the available pins you wish for your design and modify the code accordingly.

Tying the Common connections to Ground means that you will be implementing Negative Logic. That is to say that an Active Switch is indicated by a LOW (GND) on the Signal Pin of that Switch.

My code example illustrates activating the pull-up resistors for the SIPinput and PUFFinput pins so you would not need to add pull-up resistors in your design. Simply allow the switches to drive their signal low to indicate they have been activated.

Following is the Code Segment that is pertinent to implementing this SIP&PUFF Switch in my design:

// ----------------------------------------------------------------
// SIP & PUFF CONTROL CODE SEGMENT
// Mark Theobald - www.DisabledAdventurers.com
// Free to Use in Any Way You Like!
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// PIN ASSIGNMENTS
// ----------------------------------------------------------------
int PUFFinput = 9;
int SIPinput = 10;

// ----------------------------------------------------------------
// TIME CONSTANTS - For 16MHz Oscillator
// ----------------------------------------------------------------
long VeryLongCt = 100000; //Approximately 2 seconds
long MinLongCt = 20000; //Approximately 0.6 second
long DebounceCt = 4000; //Approximately 0.1 second

// ----------------------------------------------------------------
// ----------------------------------------------------------------
void setup() {

pinMode( SIPinput, INPUT );
pinMode( PUFFinput, INPUT );

digitalWrite( SIPinput, HIGH ); //Turn on 20k pullup resistors
digitalWrite( PUFFinput, HIGH ); } //to simplify switch input

// ----------------------------------------------------------------
// ----------------------------------------------------------------
void loop() {
int GotCmd;
long Counter;

Counter = 0; //Start each loop with the Counter Reset to 0
GotCmd = 0;

while ( ! digitalRead( SIPinput ) ) { //Negative Logic is being used!

//Add code here to monitor the outside world and react as needed

if ( Counter++ > VeryLongCt ) {
GotCmd++;
//Add code to RespondToVeryLongSip(); without waiting for Sip release

while ( ! digitalRead( SIPinput ) ) //then wait for Sip release

//Add code here to monitor the outside world and react as needed

} }

if ( ! GotCmd ) { //There was not a VERY Long SIP...
if ( Counter > MinLongCt ) //but there was a Long SIP
//Add code to RespondToLongSip();

else if ( Counter > DebounceCt ) //or, there was a valid Short Sip
//Add code to RespondToShortSip(); }

Counter = 0;
GotCmd = 0;

while ( ! digitalRead( PUFFinput ) ) {

//Add code here to monitor the outside world and react as needed

if ( Counter++ > VeryLongCt ) {
GotCmd++;
//Add code to RespondToVeryLongPuff(); without waiting for Puff release

while ( ! digitalRead( PUFFinput ) ) //then wait for Puff release

//Add code here to monitor the outside world and react as needed

} }

if ( ! GotCmd ) {
if ( Counter > MinLongCt ) //Long PUFF
//Add code to RespondToLongPuff();

else if ( Counter > DebounceCt )
//Add code to RespondToShortPuff(); } } }

// ----------------------------------------------------------------
// END OF CODE SEGMENT
// ----------------------------------------------------------------

Note that the Code Segments for the SIP section and the PUFF section are identical.

When a SIP or PUFF is held for a long time (2+ seconds), the code assumes that some action must be taken immmediately without waiting for the SIP or PUFF to be released. Otherwise, the code will run "RespondTo...()" functions based on Very Short ( 0.1 to 0.6 second ) Sips and Puffs, and somewhat Longer ( 0.6 to 2 seconds ) Sips and Puffs. The Time Constants may be adjusted as the designer feels is neccessary.

Step 6: WHAT ELSE?

Your particular design will dictate what your housing may look like as well as how you will be supplying power to the arduino uController. The Arduino uControlers run very well on a wide range of voltages, as low as 4VDC up to about 15VDC, giving you many choices on how to power it.

If you need to talk to a USB Arduino such as the Duemilinove over a Serial (Rs-232) port, take a look at SparkFun.com's TTL to RS-232 Level Shifter boards. They come in completed assemblies and in kit form, starting at about $6. I like the one in the photo attached to this section, RS232 Shifter SMD No DB9 sku: PRT-08780, for ~$10.

Microcontroller Contest

Participated in the
Microcontroller Contest