Friday, 18 September 2020

Snipping Key

There's been a new screen Snipping function in Windows10 for a while, but I've preferred using the old Snipping Tool. But I worked out a way to make screen snipping simpler, by building myself a Snipping Key.

The new snipping function works when you hit the Windows Key and Shift and S, which is okay, but rather fiddly if you are doing snipping frequently. My project will send that keyboard combination to the computer with a single button press.

This is a rebuild of the Any Key project Previously made. This was a comedy project that produced a button that, when you pushed it, would randomly press ANY key on the keyboard. Theres a little video I made on YouTube.

I didn't document that project, but this rebuild changes only the upper button shell and some of the Adruino Code.

Here's the exploded design view from Fusion360

Inside is an Arduino Nano running the following code;


#include <Keyboard.h>

/*
  Snipping Key
  by Andy Lakin-Hall September 2020

  For the Arduino NANO.

  Sends WIN+SHIFT+S.

  Windows key is KEY_RIGHT_GUI in the Keyboard library.

*/

const int Button_Pin = 2;         // input pin for Button
int TimeToWait = 100;               // Keyboard delay
int RandomKey =  65;
int PIEZO = 3;


void setup() {

  // make the pushButton pin an input:
  pinMode(Button_Pin, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);

  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {

  //read the button:
  int Button_State = digitalRead(Button_Pin);

if (Button_State == LOW) {
  //RandomKey == random(32, 128);
  digitalWrite(LED_BUILTIN,HIGH);
  //Keyboard.write(random(32, 128));
  Keyboard.press(KEY_LEFT_GUI);
  Keyboard.press('S');
  Click();
  delay(TimeToWait);
  Keyboard.releaseAll();
  while (digitalRead(Button_Pin) == LOW) {
    //do nothing until pin goes HIGH
    delay(TimeToWait);
  }
}
  else {
    digitalWrite(LED_BUILTIN,LOW);
    Keyboard.releaseAll();
  }
 
}

//******************************************************
// ************************************************************************
//do a high bleep
void HighBleep()
{
  tone(PIEZO, 300, 250);
}
// ************************************************************************
// ************************************************************************
//************************************************************************
//do a click
void Click()
{
    for(int i = 1;i < 6;i++){
      tone(PIEZO, i*550, 10);
    }
}

CH32V203 Big Round Button

Having successfully uploaded the Blink code to the  CH32V203 , the next task is to try the HID button demo. The circuit I’m using has two bu...