This is the stereotypical SPST toggle switch. These are everywhere.
A Home for Every Switch
I like toggle switches. I like the tactile impression they make on my finger as I flip them. The satisfying click that tells me, 'yes, it did'.
But sometimes mounting them is a bit of a problem. Thanks to the magic of OpenSCAD and Prusa, I can fix that without a lot of trouble.
I Give You a Parametric Toggle Switch Housing
This is the housing I printed for that switch.
The Reason
This application is what got me started on all this. It works great!
In my Bug project, I have four strings of 12VDC LED lights. I have a normal household light switch by the side door that turns them all on and off. I wanted to be able to control the strings individually, so I ordered up some of these SPST switches. I then needed a nice way to mount them, so I thought I would try my hand at designing my own. It turned out great!
I print this in two parts: the base and the main body which fits into the base. When I say 'fits' I mean snug. The exterior dimension of the main body is the same as the interior dimension of the base. Once you get the body slid into the base, it ain't going nowhere. It's perfect!
In this view, both of the two modules in the openSCAD file are uncommented. The base and the main body are separate parts.
Once you put in how many switches you need to house (3 max), and the dimensions of the switch, you are pretty much done. You can tweak the other parameters like wall thickness if you want, but for my needs with these switches, these are fine.
As always, because it's in openSCAD, it's all right there for you to manipulate. So go ahead! Enjoy!
This is the base. I print it in the orientation it is shown here.
This is the main body. I print it upside down so no supports are needed. I import both the base and the main body into the slicer and process them into one gcode file.
Putting them together may seem impossible at first, but with a little perseverance and some force, they will slide together begrudgingly. And no adhesive is required. I tried to get one of them apart, but was not able to do it.
The Code
// sw_housing.scad - 2024 Gregory Sanders
// dr.gerg@drgerg.com
// Housing for SPST Toggle Switch
switchqty = 1;
shaftdia = 12; // shaftdia is the diameter of the mounting screw portion of the switch
switchwidth = 16;
switchlength = 30;
switchheight = 27;
interswspace = 4; // interswspace is free space on each side of the switch
wirespace = 4; // wirespace is the amount of space under the switch
interiorx = (switchwidth+(interswspace*2))*switchqty;
interiory = switchlength+(interswspace*2);
interiorz = switchheight+(wirespace);
wallthickness = 3;
basetaby = 10;
baseinteriorx = interiorx+wallthickness*2;
baseinteriory = interiory+wallthickness*2;
basez = 10;
wirehole = 3; // wirehole diameter for a single switch. Automatically enlarged for multiple switches
$fn=128;
module swbox(){
difference(){
difference(){
cube([interiorx+wallthickness*2,interiory+wallthickness*2,interiorz+wallthickness]);
translate([wallthickness,wallthickness,-wallthickness])
cube([interiorx,interiory,interiorz+wallthickness]);
};
translate([-10,baseinteriory/2,0])
rotate([0,90,0])
cylinder(20,r=wirehole*switchqty);
};
}
module basetabs(){
difference(){
translate([0,-basetaby-wallthickness,0])
cube([baseinteriorx,basetaby,wallthickness]);
union(){
translate([baseinteriorx/4,-wallthickness-basetaby/2,-4])
cylinder(20,2,2);
translate([(baseinteriorx/4)*3,-wallthickness-basetaby/2,-4])
cylinder(20,2,2);
}
}
difference(){
translate([0,baseinteriory+wallthickness,0])
cube([baseinteriorx,basetaby,wallthickness]);
union(){
translate([baseinteriorx/4,baseinteriory+wallthickness+basetaby/2,-4])
cylinder(20,2,2);
translate([(baseinteriorx/4)*3,baseinteriory+wallthickness+basetaby/2,-4])
cylinder(20,2,2);
}
}
}
module basebody(){
difference(){
difference(){
translate([-wallthickness,-wallthickness,0])
cube([baseinteriorx+wallthickness*2,baseinteriory+wallthickness*2,basez]);
translate([0,0,-wallthickness])
cube([baseinteriorx,baseinteriory,basez+4]);
};
translate([-10,baseinteriory/2,0])
rotate([0,90,0])
cylinder(20,r=wirehole*switchqty);
};
}
module sh(){
cylinder(20,d=shaftdia+1);
}
module mainbody(){
difference(){
swbox();
union(){
if (switchqty == 1) {
translate([baseinteriorx/2,baseinteriory/2,interiorz-3])
sh();}
if (switchqty == 2){
translate([(baseinteriorx/2)-(switchwidth/2)-wallthickness,baseinteriory/2,interiorz-3])
sh();
translate([(baseinteriorx/2)+(switchwidth/2)+wallthickness,baseinteriory/2,interiorz-3])
sh();
}
if (switchqty == 3){
translate([(baseinteriorx/3)-switchwidth/2,baseinteriory/2,interiorz-3])
sh();
translate([(baseinteriorx/2),baseinteriory/2,interiorz-3])
sh();
translate([baseinteriorx-(baseinteriorx/3)+switchwidth/2,baseinteriory/2,interiorz-3])
sh();
}
}
};
}
module base(){
basebody();
basetabs();
}
//
// Uncomment the one you want to export for printing.
// Uncomment both to see the final product.
//
mainbody();
base();
I hope you get some joy from this. For me, the housings are things that work.