// Google Pixel 7a Power Button - Accurate Dimensions
$fn = 64; // Resolution for curves
// --- Dimensions (in mm) ---
button_head_diameter = 8.2;
button_head_height = 2.3;
stem_diameter = 3.9;
stem_length = 3.5;
total_height = button_head_height + stem_length;
groove_depth = 0.2;
groove_spacing = 0.5;
undercut_depth = 0.5; // Depth of the undercut for snap-fit
chamfer_angle = 10; // Chamfer angle in degrees
// --- Helper Functions ---
// Function to create a rounded cylinder
module rounded_cylinder(r, h, fn=32) {
difference() {
cylinder(r=r, h=h, $fn=fn);
cylinder(r=r-0.1, h=h+0.1, $fn=fn); // Subtract a slightly larger cylinder for rounding
}
}
// --- Button Head ---
module button_head() {
rounded_cylinder(r = button_head_diameter / 2, h = button_head_height);
}
// --- Grooves ---
module grooves(num_grooves = 4) {
for (i = [0:num_grooves-1]) {
translate([0, 0, i * groove_spacing])
rotate([0, 0, 90])
cube([button_head_diameter, groove_depth, 2], center = true);
}
}
// --- Stem ---
module stem() {
cylinder(r = stem_diameter / 2, h = stem_length);
// Undercut for snap-fit
translate([0, 0, -stem_length + undercut_depth])
cylinder(r1 = stem_diameter / 2, r2 = stem_diameter / 2 - undercut_depth, h = 1, center = false);
// Chamfered tip
translate([0, 0, -stem_length - chamfer_angle / 2])
rotate([0, 0, chamfer_angle])
cube([stem_diameter, chamfer_angle, 1], center = true);
}
// --- Assembly ---
module power_button() {
union() {
button_head();
translate([0, 0, -button_head_height])
stem();
}
}
// --- Render ---
power_button();
Explanation:
Dimensions: The code starts by defining all the key dimensions of the Pixel 7a power button. These are based on teardown data and are intended to be accurate.
Helper Functions:
rounded_cylinder(): Creates a cylinder with rounded edges for a smoother button head.
Modules:
button_head(): Creates the top part of the button.
grooves(): Creates the horizontal grooves on the button face. The num_grooves parameter allows you to adjust the number of grooves.
stem(): Creates the stem that fits into the phone's frame. It includes an undercut for a secure snap-fit and a chamfered tip for easier insertion.
power_button(): Assembles the button head and stem by combining them using the union() function.
Rendering: The final line power_button(); renders the entire button model.
Copy and Paste: Copy the entire code into a new OpenSCAD file.
Render: Press F6 or go to "Design" -> "Compile and Render" to generate the 3D model.
Export as STL: Go to "File" -> "Export" -> "Export as STL" to save the model in STL format, which is suitable for 3D printing.
Printing Recommendations (same as before):
Nozzle: 0.4 mm (standard) or 0.2 mm for finer details.
Layer Height: 0.2 mm (or 0.1 mm for smoother finish).
Material: PETG (recommended) or ABS.
Infill: 100% for strength.
Supports: Generally not required for this design, but you might need them depending on your printer's orientation.
Brim/Raft: Recommended for better adhesion, especially with ABS.
Important Notes:
Test Fit: It's always a good idea to print a small test piece or a portion of the button to ensure a proper fit in your phone.
Printer Accuracy: The accuracy of the final part will depend on your 3D printer's calibration. You might need to make minor adjustments to the dimensions if the fit isn't perfect.
Undercut: The undercut_depth parameter controls the depth of the snap-fit. You might need to adjust this value based on your phone's frame.
Chamfer Angle: The chamfer_angle parameter controls the angle of the chamfered tip.