Last active
January 5, 2019 15:53
-
-
Save effedebe/7df5d91605da14a0a4ca694fabddfc62 to your computer and use it in GitHub Desktop.
Library to build electronic pinheader(parameters) component with openscad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Pin_header(pos = [0,0,0],rot = [0,0,0], col = 3, row = 1, horiz = false, female = false) | |
| { | |
| plastic_h = female ? 7.0 : 2.5; | |
| plastic_tz = female ? 3.0 : 5.0; | |
| metal_h = female ? 2.0 : 10.0; | |
| metal_b = female ? 3.0 : 5.0; | |
| translate (pos) | |
| rotate(rot) | |
| for (i=[0:abs(col)-1]) | |
| for (j=[0:abs(row)-1]) | |
| { | |
| translate ([i*2.54*(col/abs(col)),j*2.54*(row/abs(row)),0]) | |
| if (horiz) | |
| union() | |
| { | |
| translate ([0,-1.,5]) | |
| rotate([90,0,0]) | |
| difference() | |
| { | |
| union() | |
| { | |
| color ([.1,.1,.1]) | |
| linear_extrude( height = plastic_h, center = false, convexity = 10) | |
| union() | |
| { | |
| square(size = 2.4 , center = true); | |
| if (i<abs(col)-1) | |
| { | |
| translate ([1.2,0,0]) | |
| square(size = [1,2] , center = true); | |
| } | |
| if (j<abs(row)-1) | |
| { | |
| translate ([0,1.2,0]) | |
| square(size = [2,1] , center = true); | |
| } | |
| } | |
| if (female) | |
| { | |
| color ([.5,.5,.5]) | |
| translate ([0,0,plastic_h]) | |
| cylinder( $fn = 16, d=1.5, h = .3, center = true); | |
| } | |
| } | |
| if (female) | |
| { | |
| color ([.5,.5,.5]) | |
| translate ([0,0,5]) | |
| cylinder( $fn = 16, d=1, h = plastic_h*0.7, center = true); | |
| } | |
| } | |
| color ([.5,.5,.5]) | |
| { | |
| translate ([0,0,0]) | |
| linear_extrude( height = 5.0, center = false, convexity = 10) | |
| square(size = 0.6 , center = true); | |
| translate ([0,.3,5]) | |
| rotate([90,0,0]) | |
| linear_extrude( height = metal_h, center = false, convexity = 10) | |
| square(size = 0.6 , center = true); | |
| } | |
| } | |
| else | |
| union() | |
| { | |
| translate ([0,0,plastic_tz]) | |
| rotate([00,0,0]) | |
| difference() | |
| { | |
| union() | |
| { | |
| color ([.1,.1,.1]) | |
| linear_extrude( height = plastic_h, center = false, convexity = 10) | |
| union() | |
| { | |
| square(size = 2.4 , center = true); | |
| if (i<abs(col)-1) | |
| { | |
| translate ([1.2,0,0]) | |
| square(size = [1,2] , center = true); | |
| } | |
| if (j<abs(row)-1) | |
| { | |
| translate ([0,1.2,0]) | |
| square(size = [2,1] , center = true); | |
| } | |
| } | |
| if (female) | |
| { | |
| color ([.5,.5,.5]) | |
| translate ([0,0,plastic_h]) | |
| cylinder( $fn = 16, d=1.5, h = .3, center = true); | |
| } | |
| } | |
| if (female) | |
| { | |
| color ([.5,.5,.5]) | |
| translate ([0,0,5]) | |
| cylinder( $fn = 16, d=1, h = plastic_h*0.7, center = true); | |
| } | |
| } | |
| color ([.5,.5,.5]) | |
| { | |
| translate ([0,0,0]) | |
| linear_extrude( height = metal_h + metal_b, center = false, convexity = 10) | |
| square(size = 0.6 , center = true); | |
| } | |
| } | |
| } | |
| } | |
| Pin_header(pos = [0,20,0],rot = [0,0,0], col = 5, row = 3, horiz = false); | |
| Pin_header(pos = [0,0,0],rot = [0,0,90],col = 5, row = 1, horiz = true); | |
| Pin_header(pos = [20,20,0],rot = [0,0,0], col = 5, row = 3, horiz = false, female = true); | |
| Pin_header(pos = [20,0,0],rot = [0,0,90],col = 5, row = 1, horiz = true , female = true); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment