Arnov Sharma
Published © MIT

PastePal Version 2

PastePal is a macropad, and this second version features five MX Switches along with a small 128x32 OLED

BeginnerFull instructions provided1 hour164
PastePal Version 2

Things used in this project

Hardware components

Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
×1

Software apps and online services

Fusion
Autodesk Fusion
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Seeed Studio Fusion PCB/PCBA
Seeed Studio Fusion PCB/PCBA

Story

Read more

Custom parts and enclosures

cad file

Schematics

SCH

Code

code

C/C++
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Keyboard.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int buttonCopyPin = 0; // Pin for the copy button
const int buttonPastePin = 1; // Pin for the paste button
const int buttonScrollUpPin = 2; // Pin for the page scroll up button
const int buttonScrollDownPin = 3; // Pin for the page scroll down button
const int buttonEnterPin = 6; // Pin for the enter button

void setup() {
  // Initialize the OLED display
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display();
  delay(2000);
  display.clearDisplay();

  // Initialize the buttons
  pinMode(buttonCopyPin, INPUT_PULLUP);
  pinMode(buttonPastePin, INPUT_PULLUP);
  pinMode(buttonScrollUpPin, INPUT_PULLUP);
  pinMode(buttonScrollDownPin, INPUT_PULLUP);
  pinMode(buttonEnterPin, INPUT_PULLUP);

  // Initialize the Keyboard library
  Keyboard.begin();
}

void loop() {
  if (digitalRead(buttonCopyPin) == LOW) {
    display.clearDisplay();
    display.setTextSize(3);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(20, 5);
    display.print("Copy");
    display.display();
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press('c');
    delay(100);
    Keyboard.releaseAll();
    delay(500); // Debounce delay
  }

  if (digitalRead(buttonPastePin) == LOW) {
    display.clearDisplay();
    display.setTextSize(3);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(20, 5);
    display.print("Paste");
    display.display();
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press('v');
    delay(100);
    Keyboard.releaseAll();
    delay(500); // Debounce delay
  }

  if (digitalRead(buttonScrollUpPin) == LOW) {
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(10, 5);
    display.print("Scroll UP");
    display.display();
    Keyboard.press(KEY_PAGE_UP);
    delay(100);
    Keyboard.releaseAll();
    delay(500); // Debounce delay
  }

  if (digitalRead(buttonScrollDownPin) == LOW) {
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(10, 5); // Adjusted cursor position
    display.print("Scroll Down");
    display.display();
    Keyboard.press(KEY_PAGE_DOWN);
    delay(100);
    Keyboard.releaseAll();
    delay(500); // Debounce delay
  }

  if (digitalRead(buttonEnterPin) == LOW) {
    display.clearDisplay();
    display.setTextSize(3);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(25, 5);
    display.print("Enter");
    display.display();
    Keyboard.press(KEY_RETURN);
    delay(100);
    Keyboard.releaseAll();
    delay(500); // Debounce delay
  }
}

Credits

Arnov Sharma
352 projects • 360 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.

Comments