Ir para conteúdo
3DFinder
Entrar

Você está no 3DFinder

Buscamos em Thingiverse, MakerWorld e Printables ao mesmo tempo para te dar o melhor de cada uma.

Buscar mais como este
Modelo 3D Macro Button Box - 4 button/3 switch por bradsprinterworks no MakerWorld

Descrição

This design may be changing over time with new designs and updates, but the hardware will stay the same!

Description

A Macro Button box made with momentary buttons, toggle switches and an Arduino pro micro clone that mounts to the front of a desk or table. I wanted to make a macro box for Elite Dangerous so I could open up some hot keys on my keyboard and also to add a cool factor to the game. I made a quick design to accommodate that. I used a clamp as a base model and went from there (uses the threaded knobs from user Wilco - C-Clamp / G-Clamp 01 - 04). It has a 5 degree shifted face so it aims slightly up towards the user. No supports are needed for this build and the print profile will have everything you need to make it work and all parts fit on the mini or higher. You could always buy one of these, but i thought “why not try and make one?”. I have added the parts I used to create this below.

 

Code

Using a simple Arduino code (generated by chatGPT because AI is getting crazy good at coding, also linked below) I was able to get the buttons/switches to mimic a HID Keyboard and use it for elite. One box uses only half the Arduino inputs, so you could easily make two and fill up the rest with more buttons! Use the code below to see which buttons go where on the board, but you can always customize to whatever you want.

 

#include <Keyboard.h>

// Define button pins
const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int buttonPin3 = 4;
const int buttonPin4 = 5;

// Define toggle switch pins
const int toggleSwitchPin1 = 6; // First toggle switch
const int toggleSwitchPin2 = 7; // Second toggle switch (Tab + C)
const int toggleSwitchPin3 = 8; // Third toggle switch

// Variables to store the previous state of each toggle switch
bool lastSwitchState1 = HIGH;
bool lastSwitchState2 = HIGH;
bool lastSwitchState3 = HIGH;

void setup() {
// Set button pins as input with internal pull-up resistors
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(buttonPin4, INPUT_PULLUP);

// Set toggle switch pins as input with internal pull-up resistors
pinMode(toggleSwitchPin1, INPUT_PULLUP);
pinMode(toggleSwitchPin2, INPUT_PULLUP);
pinMode(toggleSwitchPin3, INPUT_PULLUP);

// Start the keyboard communication
Keyboard.begin();
}

void loop() {
// Read the current state of each toggle switch
bool currentSwitchState1 = digitalRead(toggleSwitchPin1);
bool currentSwitchState2 = digitalRead(toggleSwitchPin2);
bool currentSwitchState3 = digitalRead(toggleSwitchPin3);

// Check if the first toggle switch state has changed
if (currentSwitchState1 != lastSwitchState1) {
// Toggle switch 1 state changed, send Ctrl + Shift + E
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('e');
delay(200); // Increased delay to ensure the key press is registered
Keyboard.releaseAll();
}

// Check if the second toggle switch state has changed
if (currentSwitchState2 != lastSwitchState2) {
// Toggle switch 2 state changed, send Tab + C
Keyboard.press(KEY_TAB);
Keyboard.press('c');
delay(200); // Increased delay to ensure the key press is registered
Keyboard.releaseAll();
}

// Check if the third toggle switch state has changed
if (currentSwitchState3 != lastSwitchState3) {
// Toggle switch 3 state changed, send Ctrl + Shift + G
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('g');
delay(200); // Increased delay to ensure the key press is registered
Keyboard.releaseAll();
}

// Update the last switch states
lastSwitchState1 = currentSwitchState1;
lastSwitchState2 = currentSwitchState2;
lastSwitchState3 = currentSwitchState3;

// Check each button and send corresponding key press with Ctrl and Shift
if (digitalRead(buttonPin1) == LOW) {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('a');
delay(200); // Increased delay for buttons
Keyboard.releaseAll();
}

if (digitalRead(buttonPin2) == LOW) {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('b');
delay(200); // Increased delay for buttons
Keyboard.releaseAll();
}

if (digitalRead(buttonPin3) == LOW) {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('c');
delay(200); // Increased delay for buttons
Keyboard.releaseAll();
}

if (digitalRead(buttonPin4) == LOW) {
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('d');
delay(200); // Increased delay for buttons
Keyboard.releaseAll();
}
}

 

Materials

Materials used in this project (Links not affiliated, just what I used)

 

  • (1) Arduino Pro Micro/Leonardo - Amazon link
  • (3) Switches - Amazon Link
  • (4) Buttons - Amazon Link - 16 mm
  • Many Jumper wires/wires (with solder, shrink, etc)
  • (4) M3x8 Machine Screws
  • (4) M3 heat set inserts

 

MakerWorld

Macro Button Box - 4 button/3 switch

Publicado em 29 de ago de 2024

12
Curtidas
20
Downloads
40
Coleções
6
Impressões
Categoria Electronics
Tags
macro button box keyboard controller arduino micro leonardo switch wiring elite dangerous
Licença BY-NC
Ver no MakerWorld (abre em nova aba)