squeeze.scad 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. //This object changes its state when the bottom half gets squeezed.
  2. //Water will be squeezed from the bottom chamber into the top one where it can be detected.
  3. //Render conductive or non-conductive parts
  4. conductive = false;
  5. //Render the cross section or complete object
  6. crossSection = true;
  7. //Add a hole to fill the object after finishing printing
  8. fillLater = false;
  9. //Diameter of the conductive part that will be on the touch screen
  10. sizeScreen=4.0;
  11. //Diameter of the conductive part that will be connected to the finger
  12. sizeFinger=4.0;
  13. //Bottom cylinder
  14. module bottomCylinder() {
  15. translate([0,0,-10])
  16. cylinder(r=13,h=20, $fa=1, $fs=0.5, center=true);
  17. }
  18. //Bottom cut out cylinder where the water will be filled in
  19. module bottomCutout() {
  20. color("blue")
  21. translate([0,0,-9])
  22. cylinder(r=8,h=18, $fa=1, $fs=0.5, center=true);
  23. }
  24. //Top cylinder
  25. module topCylinder() {
  26. translate([0,0,10])
  27. cylinder(r=13,h=20, $fa=1, $fs=0.5, center=true);
  28. }
  29. //Top cot out where the water will be caught
  30. module topCutout() {
  31. color("blue")
  32. translate([0,0,5])
  33. cylinder(r=8,h=10, $fa=1, $fs=0.5, center=true);
  34. }
  35. //The cone for the roof, used for easier printing
  36. module topCone() {
  37. color("blue")
  38. translate([0,0,14.5])
  39. cylinder(r1=8, r2=0,h=9, $fa=1, $fs=0.5, center=true);
  40. }
  41. //The hole through which the water can be filled in later
  42. module fillInHole() {
  43. color("blue")
  44. translate([0,0,19])
  45. cylinder(r=1,h=2, $fa=1, $fs=0.5, center=true);
  46. }
  47. //Outer part of the cone
  48. module coneOutside() {
  49. translate([0,0,5])
  50. cylinder(10,10,2, $fa=1, $fs=0.5, center=true);
  51. }
  52. //Inner cut out part of the cone
  53. module coneCutout() {
  54. translate([0,0,5])
  55. cylinder(10,8,1, $fa=1, $fs=0.5, center=true);
  56. }
  57. //The cone where the water gets squeezed through, the water will be caught on its top
  58. module coneMid() {
  59. difference() {
  60. coneOutside();
  61. coneCutout();
  62. }
  63. }
  64. //Isolation around the conductive bottom part
  65. module isolationBottom() {
  66. difference() {
  67. color("blue")
  68. translate([0,-12-sizeScreen/2,-6])
  69. cube([4+sizeScreen,4+sizeScreen,28], center=true);
  70. topCylinder();
  71. bottomCylinder();
  72. }
  73. }
  74. //Isolation around the conductive top part
  75. module isolationTop() {
  76. difference() {
  77. color("blue")
  78. translate([0,12+sizeFinger/2,11])
  79. cube([sizeFinger+4,sizeFinger+4,18], center=true);
  80. topCylinder();
  81. bottomCylinder();
  82. }
  83. }
  84. //Bevel for the top isolation, for easier printing and recognizing what the top part is
  85. module isolationTopBevel() {
  86. difference() {
  87. color("blue")
  88. translate([0,9.9+sizeFinger/2,5-sizeFinger/2])
  89. rotate([45,0,0])
  90. cube([sizeFinger+4,1+sizeFinger*1.5,10], center=true);
  91. topCylinder();
  92. bottomCylinder();
  93. }
  94. }
  95. //Conductive bar on the top part, connected to the finger
  96. module condTop() {
  97. color("red")
  98. translate([0,12+sizeFinger/2,11])
  99. cube([sizeFinger,sizeFinger,18], center=true);
  100. }
  101. //Conductive part that connects the bar to the inside
  102. module condTopInside() {
  103. difference() {
  104. color("red")
  105. translate([0,10,4])
  106. cube([4,7,3], center=true);
  107. topCutout();
  108. }
  109. }
  110. //Conductive bar on the bottom part, connected to the touchscreen
  111. module condBottom() {
  112. color("red")
  113. translate([0,-12-sizeScreen/2,-7])
  114. cube([sizeScreen,sizeScreen,26], center=true);
  115. }
  116. //Conductive part that connects the bar to the inside
  117. module condBottomInside() {
  118. difference() {
  119. color("red")
  120. translate([0,-10,4])
  121. cube([4,7,3], center=true);
  122. topCutout();
  123. coneMid();
  124. }
  125. }
  126. //All conductive parts combined to one module
  127. module conductive() {
  128. union() {
  129. condTop();
  130. condTopInside();
  131. condBottom();
  132. condBottomInside();
  133. }
  134. }
  135. //The combined, non-conductive bottom part
  136. module combinedBottom() {
  137. difference() {
  138. bottomCylinder();
  139. union() {
  140. bottomCutout();
  141. conductive();
  142. }
  143. }
  144. }
  145. //The combined, non-conductive top part
  146. module combinedTop() {
  147. union() {
  148. coneMid();
  149. difference() {
  150. union() {
  151. topCylinder();
  152. isolationBottom();
  153. isolationTop();
  154. isolationTopBevel();
  155. }
  156. union() {
  157. conductive();
  158. topCone();
  159. topCutout();
  160. if (fillLater)
  161. fillInHole();
  162. }
  163. }
  164. }
  165. }
  166. //Combined top and bottom parts to one module.
  167. //If a printer can choose different densities for different parts, you can print the top part with 100% infill (solid) and the bottom part with ~20% (flexible)
  168. module completeObject() {
  169. union() {
  170. combinedBottom();
  171. combinedTop();
  172. }
  173. }
  174. //Render the object depending on the input
  175. if (crossSection) {
  176. difference() {
  177. if (conductive) {
  178. conductive();
  179. }
  180. else {
  181. completeObject();
  182. }
  183. translate([0,-30,-30])
  184. cube([60,60,60]) ;
  185. }
  186. }
  187. else {
  188. if (conductive) {
  189. conductive();
  190. }
  191. else {
  192. completeObject();
  193. }
  194. }