acceleration.scad 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. //This object changes its state if a specific acceleration is reached.
  2. //The necessary acceleration is dependend on the wall height.
  3. //Water will be filled into the bigger chamber and will swap over that wall into the smaller chamber where it can be detected.
  4. //Parting wall height
  5. wallHeight = 18;
  6. //Render conductive or non-conductive parts
  7. conductive = false;
  8. //Render the cross section or complete object
  9. crossSection = false;
  10. //Add a hole to fill the object after finishing printing
  11. fillLater = false;
  12. //Diameter of the conductive part that will be on the touch screen
  13. sizeScreen=4.0;
  14. //Diameter of the conductive part that will be connected to the finger
  15. sizeFinger=4.0;
  16. //The main block where everything else gets cut out
  17. module baseBlock() {
  18. cube([40,20,30], center=true);
  19. }
  20. //Adding 2 half-cylinder on the sides for easier recognition which object this is
  21. module recognitionAddition() {
  22. difference (){
  23. union() {
  24. color("green")
  25. translate([0,-10,5])
  26. cylinder(r=3,h=40, $fa=1, $fs=0.5, center=true);
  27. color("green")
  28. translate([0,10,5])
  29. cylinder(r=3,h=40, $fa=1, $fs=0.5, center=true);
  30. }
  31. baseBlock();
  32. roofAddition();
  33. }
  34. }
  35. //The smaller chamber that contains the conductive parts
  36. module conductiveChamber() {
  37. color("blue")
  38. translate([-12,0,2])
  39. cube([8,16,26], center=true);
  40. }
  41. //The bigger chamber that contains the water
  42. module initialWaterChamber() {
  43. color("blue")
  44. translate([6,0,2])
  45. cube([24,16,26], center=true);
  46. }
  47. //The wall where the water will swap over
  48. module partitionWall() {
  49. color("blue")
  50. translate([-6,0,2+(wallHeight/2)])
  51. cube([10,16,26-wallHeight], center=true);
  52. }
  53. //Addition to the main block, added later. TODO remove, add to baseBlock
  54. module roofAddition() {
  55. translate([0,0,20])
  56. cube([40,20,10], center=true);
  57. }
  58. //The roof in a 45 degree angle for better printing
  59. module roofCutout() {
  60. difference() {
  61. color("blue")
  62. translate([1,0,15])
  63. rotate([45,0,0])
  64. cube([34,11.3,11.3], center=true);
  65. translate([1,0,2])
  66. cube([34,20,20],center=true);
  67. }
  68. }
  69. //The hole through which the water can be filled in later
  70. module fillInHole() {
  71. color("blue")
  72. translate([7,0,23])
  73. cylinder(r=1,h=4, $fa=1, $fs=0.5, center=true);
  74. }
  75. //Conductive bar on the wall which is connected to the finger
  76. module condBarWall() {
  77. color("red")
  78. translate([-16.5,0,-8])
  79. cube([1,14,4], center=true);
  80. }
  81. //Conductive part on the outside where the finger has to be placed
  82. module condFinger() {
  83. color("red")
  84. translate([-19,0,0])
  85. rotate([0,90,0])
  86. cylinder(r=sizeFinger/2,h=2, $fa=1, $fs=0.5, center=true);
  87. }
  88. //A conductive part inside of a wall that connects the two modules above
  89. module condConnectionFingerWall() {
  90. color("red")
  91. translate([-17.5,0,-4])
  92. cube([1,6,12], center=true);
  93. }
  94. //Conductive bar on the floor that is connected to the touch screen
  95. module condBarFloor() {
  96. color("red")
  97. translate([-10,0,-11.5])
  98. cube([4,14,1], center=true);
  99. }
  100. //Conductive part on the outside that connects to the touchscreen
  101. module condFloorScreen() {
  102. color("red")
  103. translate([-10,0,-13.5])
  104. cylinder(r=sizeScreen/2,h=3, $fa=1, $fs=0.5, center=true);
  105. }
  106. //Combine all conductive parts to one module
  107. module conductive() {
  108. union() {
  109. condBarFloor();
  110. condBarWall();
  111. condFinger();
  112. condConnectionFingerWall();
  113. condFloorScreen();
  114. }
  115. }
  116. //The complete non-conducitve object
  117. module completeObject() {
  118. difference() {
  119. union() {
  120. baseBlock();
  121. roofAddition();
  122. recognitionAddition();
  123. }
  124. union() {
  125. conductiveChamber();
  126. initialWaterChamber();
  127. conductive();
  128. partitionWall();
  129. roofCutout();
  130. if (fillLater)
  131. fillInHole();
  132. }
  133. }
  134. }
  135. //Render the object depending on the input
  136. if (crossSection) {
  137. difference() {
  138. if (conductive) {
  139. conductive();
  140. }
  141. else {
  142. completeObject();
  143. }
  144. translate([-30,-60,-30])
  145. cube([60,60,60]);
  146. }
  147. }
  148. else {
  149. if (conductive) {
  150. conductive();
  151. }
  152. else {
  153. completeObject();
  154. }
  155. }