Murchx
Published

Pi Pico macro keyboard

Raspberry Pi Pico macro keyboard to simplify the workflow of some creative software or just for everyday use.

BeginnerWork in progress6,445
Pi Pico macro keyboard

Things used in this project

Hardware components

Raspberry Pi Pico
Raspberry Pi Pico
×1
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
My prototype has only 1
×2
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
Switches / buttons of your choice (not added to my prototype)
×4
Resistor 10k ohm
Resistor 10k ohm
3 pieces are required for each rotary encoder with push-button, 2 if just rotary encoder, 1 piece are required for each switches / button
×10

Story

Read more

Schematics

Prototype scheme

Code

Raspberry Pi Pico macro keyboard

Arduino
Test code for Rotary encoder with push-button function test. Rotate knob for volume, press to play / pause.
#include <USBKeyboard.h>

USBKeyboard keyb;
int encA = 14;
int encB = 15;
int btn = 16;

void setup() {
  pinMode(encA, INPUT); 
  pinMode(encB, INPUT);
  pinMode(btn, INPUT);
  // pinMode(LED_BUILTIN, OUTPUT);
}

int main(void) {
  while(1) {

    if(digitalRead(encA) == HIGH || digitalRead(encB) == HIGH) {
      digitalWrite(LED_BUILTIN, HIGH);
      delay(2);
      if(digitalRead(encA) == HIGH) {
        keyb.media_control(KEY_VOLUME_UP);
      }
      else if(digitalRead(encB) == HIGH) {
        keyb.media_control(KEY_VOLUME_DOWN);
      }
      else {}
      while(digitalRead(encA) == HIGH || digitalRead(encB) == HIGH) {
        delay(20);
      }
      digitalWrite(LED_BUILTIN, LOW);
    }

    else if(digitalRead(btn) == HIGH) {
      digitalWrite(LED_BUILTIN, HIGH);
      delay(5);
      keyb.media_control(KEY_PLAY_PAUSE);
      while(digitalRead(btn) == HIGH) {
        delay(50);
      }
      digitalWrite(LED_BUILTIN, LOW);
    }

    // keyb.printf("Hello World\r\n");
    // keyb.media_control(KEY_VOLUME_DOWN);
    // keyb.key_code('d', KEY_LOGO);
    // keyb.key_code('q', 101); // ALT 100; SHIFT 10; CTRL 1; CTRL+SHIFT 11 
    // keyb.key_code('d');
    // keyb.key_code(0, KEY_LOGO);
    // keyb._putc(KEY_F1);
    // keyb._putc('d');
  }
}

Credits

Murchx

Murchx

0 projects • 0 followers

Comments