Skip to content

Instantly share code, notes, and snippets.

@ednisley
Created January 15, 2026 00:00
Show Gist options
  • Select an option

  • Save ednisley/20cd9d651c7b5399b68485b1df443bc8 to your computer and use it in GitHub Desktop.

Select an option

Save ednisley/20cd9d651c7b5399b68485b1df443bc8 to your computer and use it in GitHub Desktop.
OpenSCAD source code: Light Guide plate for a single-LED nightlight
// Nightlight light guide
// Ed Nisley - KE4ZNU
// 2026-01-13
include <BOSL2/std.scad>
Layout = "Show"; // [Show,Build,Plate,Base,Pipe]
/* [Hidden] */
HoleWindage = 0.2;
Protrusion = 0.1;
NumSides = 10*3*4;
$fn=NumSides;
ID = 0;
OD = 1;
LENGTH = 2;
function ChordRadius(m,c) = (m^2 + (c^2)/4) / (2*m);
PlateThick = 2.0;
PlateOA = [60.0,50.0,PlateThick];
PlateRound = 5.0;
PlateTaper = 1.0;
PlateAngle = atan(-2/60); // original plate angle, far end closer to wall
PlateM = 2.4;
PlateRadius = ChordRadius(PlateM,PlateOA.x); // light guide plate
echo(PlateRadius=PlateRadius);
WallThick = 2.0;
MountOA = [23.4,17.0,5.5];
MountRadius = ChordRadius(4.3,MountOA.x); // base arc in housing
echo(MountRadius=MountRadius);
PipeThick = 5.0;
//----------
// Define shapes
// Oddly intricate base fitting into housing
// Replete with magic numbers
module Base() {
difference() {
union() {
intersection() {
cuboid([MountOA.x,MountOA.y,5.5],anchor=BOTTOM);
back(6.5)
tube(MountOA.z,or=MountRadius,wall=1.5,anchor=BOTTOM+BACK);
}
for (i=[-1,1])
right(i*18.5/2)
back(11.5)
cuboid([1.8,8.0,MountOA.z],anchor=BOTTOM+BACK);
for (i=[-1,1])
right(i*22.0/2)
cuboid([1.4,2.0,MountOA.z],anchor=BOTTOM+FRONT);
fwd(5.0)
cuboid([11.0,10.5,MountOA.z],anchor=BOTTOM+FRONT);
}
down(Protrusion)
for (j=[-1,1])
fwd(j*(1.5 + 10.0)/2)
cuboid([7.0,10.0,MountOA.z + 2*Protrusion],anchor=BOTTOM);
up(3.1)
back(7.5)
cuboid([MountOA.x,25.0,MountOA.z],anchor=BOTTOM+FRONT);
}
}
// Light guide plate
module Plate() {
xrot(PlateAngle)
zrot(90) yrot(90)
left(PlateOA.x/2)
down(PlateM + PlateThick/2)
intersection() {
up(PlateRadius)
difference() {
spheroid(PlateRadius,style="icosa");
spheroid(PlateRadius - PlateThick,style="icosa");
}
cuboid(PlateOA + [0,0,2*PlateThick],rounding=PlateRound,edges="Z",anchor=BOTTOM);
}
}
// Light pipe between base & plate
// Magic numbers to fit case opening
module Pipe() {
difference() {
intersection() {
fwd(3.0/2 - 0.2)
cuboid([MountOA.x,MountOA.y,PipeThick],rounding=0.5,edges="Z",anchor=BOTTOM+FRONT);
back(6.5)
cyl(MountOA.z,r=MountRadius,anchor=BOTTOM+BACK);
}
down(Protrusion)
back((1.5 + 10.0)/2)
cuboid([7.0,10.0,1.0 + Protrusion],anchor=BOTTOM);
}
}
module Assembly() {
Base();
up(MountOA.z)
Pipe();
up(MountOA.z + PipeThick)
Plate();
}
//----------
// Build things
if (Layout == "Base")
Base();
if (Layout == "Plate")
Plate();
if (Layout == "Pipe")
Pipe();
if (Layout == "Show" || Layout == "Build")
Assembly();
@ednisley
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment