1 / 1
Big button box — zdjęcie 1

Big button box

Zamów wydruk tego modelu

Obliczymy ostateczną cenę na podstawie wybranego pliku. Sprawdzisz ją i zaakceptujesz przed płatnością.

Zapisane na tym urządzeniu.

A big button box. Designed to house a 100 mm arcade button

Ocena
0 / 5
Polubienia
4
Pobrania
19
Wydruki
0
Wyświetlenia
154
Oceny
0

Aktualizacja u źródła:

Informacje o modelu

Źródło
Printables
Kategoria
Electronics
Licencja
Creative Commons — Attribution — Noncommercial — Share Alike

A big red button box to house a 100 mm arcade button, such as can be found on amazon . A little bit higher than the original, so that the connectors at the bottom fit more comfortably. Also, with an opening for a wire to be fed out.

For you convenience, below a script that sends button presses to a C# application (full disclosure, using CmdMessenger by yours truly)


The code below uses Adafruit_debounce and CmdMessenger to connect to an C# application over USB
#include "Adafruit_Debounce.h"
#include "DoEvery.h"
#include <CmdMessenger.h>  // CmdMessenger

// Define the button pin use any GPIO
#define BUTTON_PIN 4
#define LED_PIN 5

// Create a debounce object for the button, which will be pressed when LOW
Adafruit_Debounce button(BUTTON_PIN, HIGH);

// Blinking led variables 
bool ledState                   = 0;   // Current state of Led
const int kBlinkLed             = 13;  // Pin of internal Led

// Attach a new CmdMessenger object to the default Serial port
CmdMessenger cmdMessenger = CmdMessenger(Serial);

// This is the list of recognized commands. These can be commands that can either be sent or received. 
// In order to receive, attach a callback function to these events
enum
{
 kStatus,         , // Command to share device status with receiver
 kSetPressed      , // Command to indicate pressed button
 kSetReleased     , // Command to indicate released button
};

// Callbacks define on which received commands we take action
void attachCommandCallbacks()
{
 // Attach callback methods
 cmdMessenger.attach(OnUnknownCommand);
 //cmdMessenger.attach(kSetPressed , OnSetPressed);
 //cmdMessenger.attach(kSetReleased, OnSetReleased);
}

// Called when a received command has no attached function
void OnUnknownCommand()
{
 cmdMessenger.sendCmd(kStatus,"Command without attached callback");
}

// Setup function
void setup() 
{
 // Listen on serial connection for messages from the PC
 Serial.begin(9600);

 // Initialize the button, which will set the pull-up as well
 pinMode(LED_PIN, OUTPUT);
 button.begin();

 // Adds newline to every command
 cmdMessenger.printLfCr();  

 // Attach my application's user-defined callback methods
 attachCommandCallbacks();

 // Send the status to the PC that says the Arduino has booted
 // Note that this is a good debug function: it will let you also know 
 // if your program had a bug and the arduino restarted  
 //cmdMessenger.sendCmd(kStatus,"Arduino has started!");

 // set pin for blink LED
 pinMode(kBlinkLed, OUTPUT);
}

// Loop function
void loop() 
{
 // Update the button state
 button.update();
 
 // Process incoming serial data, and perform callbacks
 cmdMessenger.feedinSerialData();

 if (button.justPressed()) {
   digitalWrite(LED_PIN, HIGH);
   cmdMessenger.sendCmd(kSetPressed,"Pressed"); 
 }
 else if (button.justReleased()) {
   digitalWrite(LED_PIN, LOW);
   cmdMessenger.sendCmd(kSetReleased,"Released");
 }

  // Since we use a fairly basic debouncing library, we are responsible for 

 // for creating sufficient delay to read out the button state  

// when the signal has stopped bouncing

 delay(50);
}



 

Tagi