Makestreme
Published © GPL3+

A beautiful save button that looks like a floppy disk

This is a unique picture frame with a retro twist—a functional floppy disk! It also doubles as an auto-save button for your PC!

IntermediateFull instructions provided5 hours6,319
A beautiful save button that looks like a floppy disk

Things used in this project

Hardware components

Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
×1
Big Red Dome Button
SparkFun Big Red Dome Button
×1
USB Cable, USB Type C Plug
USB Cable, USB Type C Plug
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Save button arduino code

Arduino
#include <Keyboard.h>

void setup() {
  pinMode(2, INPUT_PULLUP); // Set the button pin as input with internal pull-up
  Keyboard.begin();                 // Start the USB keyboard functionality
}

void loop() {
  // Check if the button is pressed
  if (digitalRead(2) == LOW) { // Button is pressed (LOW because of pull-up)
    Keyboard.press(KEY_LEFT_CTRL); 
    Keyboard.press('s');
    delay(100); // delay to ensure the key press is registered
    Keyboard.releaseAll();         
    delay(1000); //delay to avoid multiple registers
  }
}

Autosave button code

Arduino
#include <Keyboard.h>

const int buttonPin = 2; // Pin connected to the button
int buttonState = 0;     // Variable to store button state
int lastButtonState = HIGH; // To track changes in button state
bool autoSaveEnabled = false; // Flag to track if autosave is enabled

unsigned long previousMillis = 0; // For timing the autosave interval
const unsigned long interval = 300000; // 5 minutes in milliseconds

void setup() {
  pinMode(buttonPin, INPUT_PULLUP); // Set the button pin as input with internal pull-up
  Keyboard.begin();                 // Start the USB keyboard functionality
}

void loop() {
  // Read the current button state
  buttonState = digitalRead(buttonPin);

  // Check for a button press (state change from HIGH to LOW)
  if (buttonState == LOW && lastButtonState == HIGH) {
    delay(50); // Debounce delay
    if (digitalRead(buttonPin) == LOW) { // Confirm button press
      autoSaveEnabled = !autoSaveEnabled; // Toggle autosave state
      delay(500); // Prevent rapid toggling
    }
  }
  lastButtonState = buttonState; // Update last button state

  // If autosave is enabled, check if it's time to send the save command
  if (autoSaveEnabled) {
    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis >= interval) {
      previousMillis = currentMillis; // Update the last save time
      sendSaveCommand();
    }
  }
}

void sendSaveCommand() {
  Keyboard.press(KEY_LEFT_CTRL); // Hold down the Ctrl key
  Keyboard.press('s');           // Press the 'S' key
  delay(100);                    // Short delay to ensure the key press is registered
  Keyboard.releaseAll();         // Release all keys
}

Credits

Makestreme

Makestreme

3 projects • 1 follower
I make DIY projects that are fun and interesting! An engineer by profession :) youtube.com/@makestreme

Comments