A Little Switch and Potentiometer Box for Your Arduino




Introduction: A Little Switch and Potentiometer Box for Your Arduino

Having cobbled together loads of Arduino circuits and always found myself poking switches and potentiometers through cardboard I thought it was time to produce something a little prettier. So here is how to make a lovely little box to hold 5 potentiometers and 3 switches. (along with some software to make it work)

A simple video of spinning dials, causing them to spin on screen as well:

Step 1: Parts & Tools

A few items required. Most are easily sourced hobby electronics items.

Acrylic Chassis: Several choices here
  • scroll saw - you can download a scroll saw pattern (03-POTB-ScrollSaw Pattern (A4).pdf or 03-POTB-ScrollSaw Pattern (letter).pdf). Glue it to some 3mm Acrylic and cut it out.
  • your own laser cutter - download the parts outline (PP-POTB-Acrylic Cut Parts.eps or 00-POTB-Acrylic Cut Parts.cdr). Cut them in any 3mm sheet stock
  • purchase a precut set - a mini kit for this project is available (here) - this includes the laser cut pieces as well as the required nuts and bolts ($25 Free Shipping to the USA and Canada)

Nuts & Bolts:
  • 3mm x 10mm bolt (x8)
  • 3mm x 15mm bolt (x14)
  • 3mm nut (x30)

Electronic Items:
  • Screwdriver (Philips)
  • Wire Strippers and Crimpers
  • Needle nose Pliers

Step 2: Assembly & Wiring

Sticking it all together is quite straight-forward. A word of caution the top and bottom do need to be aligned properly (this is easy to arrange as they will only line up in one orientation).

  • Simply screw everything together and insert the potentiometers and switches.

  • To wire up download the wiring diagram (05-POTB-Wiring Diagram.pdf). And run the wires to their respective nodes.

Step 3: Programming & Testing

You can use your switch box in any way you like. What is included here is a small Arduino program that polls the Switch Boxes state and sends it over its USB connection to a computer (once every 100 milliseconds). Also there is a small program written in Processing to display the state of the box. The code is all highly commented to hopefully make jumping in and making changes easy.

To get it up and running.

Option 1: (download and unzip)
  • Download the file ( 07-POTB-Arduino-SerialSwitch.zip ) from below and un-zip it into your Arduino folder. (default My Documents\Arduino\)
  • Open it in the Arduino development environment and download it to your Arduino.

Option 2: (copy and paste)
  • Copy the text of the Arduino program (from below (Appendix 1)
  • Open up the Arduino development environment. Paste the text and upload it to your board.

Processing Program
Option 1: Download an exe
  • Download the attached zip file ( 07-POTB-Processing Switch Watcher (windows exe).zip ).
  • Unzip it anywhere on your computer.
  • Run _POTB_SwitchWatcher.exe.

Option 2: Download Processing Source
  • Download the attached zip file ( 07-POTB-Processing Swtch Watcher (source).zip ).
  • Unzip anywhere on your computer.
  • Open ( _POTB_SwitchWatcher.pde ) in the Processing development environment, and run and edit to your hearts content.

To Run
  • Start the program.
  • Click on the Comm port your Arduino is attached to.
  • Watch the dials spin whilst you spin yours.

Appendix 1: Arduino Code
      /* * Potentiometer and Switch Box (POTB) - Serial Updater * For more details visit: http://www.oomlout.com/ *  * Behaviour: Will feed the state of the 5 plugged in               potentiometers and three switches to a connected              PC every 100 ms.  * * Wiring: Twist Potentiometer (01) - analog 1 *         Shoulder Potentiometer (02) - analog 3 *         Elbow Potentiometer (03) - analog 2 *         Wrist Potentiometer (04) - analog 4       *         Gripper Potentiometer (05) - analog 0 *         Switch 1 - pin 02 *         Switch 2 - pin 03  *         Switch 3 - pin 04 *          * License: This work is licenced under the Creative Commons  *          Attribution-Share Alike 3.0 Unported License. To  *          view a copy of this licence, visit  *          http://creativecommons.org/licenses/by-sa/3.0/  *          or send a letter to Creative Commons, 171 Second  *          Street, Suite 300, San Francisco, California 94105,  *          USA. *         */  //-------------------------------------------------------------------------//START OF POTENTIMETER BOX PREAMBLE//Defining constants corresponding to the pin each Potentiometer is plugged into //change to whatever you are using them for#define TWIST_POT 1      #define SHOULDER_POT 3   #define ELBOW_POT 2      #define WRIST_POT 4#define GRIPPER_POT 0    //Defining constants corresponding to the pin each Potentiometer is plugged into //change to whatever you are using them for#define SWITCH_1 2#define SWITCH_2 3#define SWITCH_3 4//Gets everything up and runningvoid setup()                  {  Serial.begin(9600);                //Starts the serial port  potbSetup();                       //sets the state of all neccesary                                      //pins and adds servos to your sketch}//The main program loopvoid loop()                     {  potbSendData();             //sends the current switch and potentiometer data  delay(100);                //waits 100 ms}//------------------------------------------------------------------------//START OF POTENTIOMETER AND SWITCH BOX (POTB) ROUTINES/* * sets up the appropriate digital inputs and outputs for your potentiometer * and switch box*/void potbSetup(){  pinMode(SWITCH_1, INPUT);          //sets the switch one pin to input  digitalWrite(SWITCH_1, HIGH);      //turns on the internal pull up resistor                                     //(this means it will read high when off and low when on   pinMode(SWITCH_2, INPUT);          //sets the switch one pin to input  digitalWrite(SWITCH_2, HIGH);      //turns on the internal pull up resistor                                     //(this means it will read high when off and low when on   pinMode(SWITCH_3, INPUT);          //sets the switch one pin to input  digitalWrite(SWITCH_3, HIGH);      //turns on the internal pull up resistor                                     //(this means it will read high when off and low when on }void potbSendData(){  Serial.print("POTB Data");  Serial.print("%SWITCH_1=");  Serial.print(getSwitchData(SWITCH_1));  Serial.print(" %SWITCH_2=");  Serial.print(getSwitchData(SWITCH_2));  Serial.print(" %SWITCH_3=");  Serial.print(getSwitchData(SWITCH_3));  Serial.print(" %TWIST_POT=");  Serial.print(getPotData(TWIST_POT));  Serial.print(" %SHOULDER_POT=");  Serial.print(getPotData(SHOULDER_POT));  Serial.print(" %ELBOW_POT=");  Serial.print(getPotData(ELBOW_POT));  Serial.print(" %WRIST_POT=");  Serial.print(getPotData(WRIST_POT));  Serial.print(" %GRIPPER_POT=");  Serial.print(getPotData(GRIPPER_POT));  Serial.print(" ");    Serial.println();}int getPotData(int potNumber){  return analogRead(potNumber);}int getSwitchData(int switchNumber){ return digitalRead(switchNumber); }  //END OF POTENTIOMETER AND SWITCH BOX (POTB) ROUTINES//---------------------------------------------------------------------------

Step 4: Finished

Well the box is done all that's left is to use it to control all your amazing Arduino projects.

To check out more interesting projects please try visiting: oomlout.com

Be the First to Share


    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge
    • Backyard Contest

      Backyard Contest

    5 Discussions


    10 years ago on Introduction

    I am in the process of building this switchbox and was wondering why you chose the three on-on (SPDT) switches when the schematic shows that only one side is being used. Wouldn't  some simple on-off (SPST) switches work for this?


    Reply 10 years ago on Introduction

    Also I have added three momentary normally open pushbutton switches and a couple led's just to make it look cooler and was wondering how to adjust the programming and the desktop _POTB_SwitchWatcher to show these changes. Thank you


    11 years ago on Step 1

    Great work! Clean job and nicely presented. What software did you use to make the Patterns?


    Reply 11 years ago on Step 1

    Hey Cheft; Thanks, in terms of the patterns I used Corel Draw. Largely because I'm a creature of habit there's an open source equivalent (Inkscape) which is pretty similar in functionality.