Exit Full View
Up

/Electronics/CoinCellLED.foocad

CoinCellLED

Holds an LED to a coin cell, for Xmas decorations etc. Should be easy to insert/remove the coin cell without the LED falling out.

The will be out of sight (e.g. inside my Springo Snowman), so they can look naff!

Note, the LED's leads are not shown on the preview. They go in and out around the castellations.

You can print small versions, but the default side allows it to be stood up on its end.

FooCAD Source Code
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*

class CoinCellLED : Model {


    var thickness = 1.8

    var size = Vector2( 24, 13 )    

    var slotLength = 4

    @Custom( about="Thickness of the battery, plus extra for the LED leads. A tight squeeze!" )
    var batteryT = 3.7

   
    override fun build() : Shape3d {

        val end = Cube( thickness*2 + batteryT, thickness, size.y - slotLength )

        val sides = Cube( thickness, size.x, size.y )
            .leftTo(end.left)
            .rightTo(end.right).also()

        val base = Cube( sides.size.x, sides.size.y, 0.6 )

        val slots = Cube( 10, 2, slotLength + 1 )
            .tileY(2, 4)
            .frontTo(4)
            .topTo(sides.top + 1)
            .leftTo(-1)
            .color("Red")

        val battery = Cylinder(3.2, 20/2).rotateY(90).previewOnly()
            .frontTo(thickness).bottomTo(0).centerXTo( (end.left + end.right)/2 )

        val led = Square( 5/2, 6 )
            .roundCorner(2,2)
            .revolve()
            .rotateX(90)
            .translate(thickness+batteryT/2, 0, size.y-3)
            .previewOnly()

        return base + end + sides - slots + battery + led
    }
}