From b2a2a16cd189f3cce75f98364a49171608242437 Mon Sep 17 00:00:00 2001 From: di0ib Date: Thu, 11 Jul 2019 16:24:53 +0000 Subject: [PATCH] Upload files to 'polyandry' --- polyandry/PolyPad_ItsyBitsy_M0.ino | 130 +++++++++++++++++++++++++++++ polyandry/PolyPad_ProMicro.ino | 130 +++++++++++++++++++++++++++++ polyandry/PolyPad_Teensy_2.0.ino | 116 +++++++++++++++++++++++++ polyandry/PolyPad_Teensy_3.5.ino | 116 +++++++++++++++++++++++++ 4 files changed, 492 insertions(+) create mode 100644 polyandry/PolyPad_ItsyBitsy_M0.ino create mode 100644 polyandry/PolyPad_ProMicro.ino create mode 100644 polyandry/PolyPad_Teensy_2.0.ino create mode 100644 polyandry/PolyPad_Teensy_3.5.ino diff --git a/polyandry/PolyPad_ItsyBitsy_M0.ino b/polyandry/PolyPad_ItsyBitsy_M0.ino new file mode 100644 index 0000000..dafe9a1 --- /dev/null +++ b/polyandry/PolyPad_ItsyBitsy_M0.ino @@ -0,0 +1,130 @@ +/* + Copyright (c) 2014-2015 NicoHood + See the readme for credit to other people. +*/ + +#include "HID-Project.h" + +const int pinLed = LED_BUILTIN; +const int MX01 = A1; +const int MX02 = A2; +const int MX03 = A3; +const int MX04 = A4; +const int MX05 = SCK; +const int MX06 = MOSI; +const int MX07 = 11; +const int MX08 = 10; +const int MX09 = 9; +const int MX10 = 7; +const int MX11 = SCL; +const int MX12 = SDA; +const int VGround = A5; + +void setup() { + // Prepare led + buttons + pinMode(pinLed, OUTPUT); + pinMode(MX01, INPUT_PULLUP); + pinMode(MX02, INPUT_PULLUP); + pinMode(MX03, INPUT_PULLUP); + pinMode(MX04, INPUT_PULLUP); + pinMode(MX05, INPUT_PULLUP); + pinMode(MX06, INPUT_PULLUP); + pinMode(MX07, INPUT_PULLUP); + pinMode(MX08, INPUT_PULLUP); + pinMode(MX09, INPUT_PULLUP); + pinMode(MX10, INPUT_PULLUP); + pinMode(MX11, INPUT_PULLUP); + pinMode(MX12, INPUT_PULLUP); + pinMode(VGround, OUTPUT); + digitalWrite(VGround, LOW); + + // Sends a clean report to the host. This is important on any Arduino type. + Keyboard.begin(); +} + +void loop() { + if (!digitalRead(MX01)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_HOME); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX02)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_UP); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX03)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_PAGE_UP); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX04)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_LEFT); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX05)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_ESC); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX06)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_RIGHT); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX07)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_END); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX08)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_DOWN); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX09)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_PAGE_DOWN); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX10)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_BACKSPACE); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX11)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_SPACE); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX12)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_ENTER); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } +} diff --git a/polyandry/PolyPad_ProMicro.ino b/polyandry/PolyPad_ProMicro.ino new file mode 100644 index 0000000..fc473fa --- /dev/null +++ b/polyandry/PolyPad_ProMicro.ino @@ -0,0 +1,130 @@ +/* + Copyright (c) 2014-2015 NicoHood + See the readme for credit to other people. +*/ + +#include "HID-Project.h" + +const int pinLed = LED_BUILTIN; +const int MX01 = 2; +const int MX02 = 3; +const int MX03 = 4; +const int MX04 = 5; +const int MX05 = 7; +const int MX06 = 8; +const int MX07 = 21; +const int MX08 = 20; +const int MX09 = 19; +const int MX10 = 18; +const int MX11 = 14; +const int MX12 = 16; +const int VGround = 6; + +void setup() { + // Prepare led + buttons + pinMode(pinLed, OUTPUT); + pinMode(MX01, INPUT_PULLUP); + pinMode(MX02, INPUT_PULLUP); + pinMode(MX03, INPUT_PULLUP); + pinMode(MX04, INPUT_PULLUP); + pinMode(MX05, INPUT_PULLUP); + pinMode(MX06, INPUT_PULLUP); + pinMode(MX07, INPUT_PULLUP); + pinMode(MX08, INPUT_PULLUP); + pinMode(MX09, INPUT_PULLUP); + pinMode(MX10, INPUT_PULLUP); + pinMode(MX11, INPUT_PULLUP); + pinMode(MX12, INPUT_PULLUP); + pinMode(VGround, OUTPUT); + digitalWrite(VGround, LOW); + + // Sends a clean report to the host. This is important on any Arduino type. + Keyboard.begin(); +} + +void loop() { + if (!digitalRead(MX01)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_HOME); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX02)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_UP); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX03)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_PAGE_UP); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX04)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_LEFT); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX05)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_ESC); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX06)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_RIGHT); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX07)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_END); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX08)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_DOWN); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX09)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_PAGE_DOWN); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX10)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_BACKSPACE); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX11)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_SPACE); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } + if (!digitalRead(MX12)) { + digitalWrite(pinLed, HIGH); + Keyboard.write(KEY_ENTER); + // Simple debounce + delay(300); + digitalWrite(pinLed, LOW); + } +} diff --git a/polyandry/PolyPad_Teensy_2.0.ino b/polyandry/PolyPad_Teensy_2.0.ino new file mode 100644 index 0000000..a5fe1e0 --- /dev/null +++ b/polyandry/PolyPad_Teensy_2.0.ino @@ -0,0 +1,116 @@ +/* Buttons to USB Keyboard Example - Special Media Player Keys + You must select Keyboard from the "Tools > USB Type" menu + This example code is in the public domain. +*/ + +#include + +// Create Bounce objects for each button. The Bounce object +// automatically deals with contact chatter or "bounce", and +// it makes detecting changes very simple. +Bounce MX01 = Bounce(4, 10); +Bounce MX02 = Bounce(5, 10); // 10 ms debounce time is appropriate +Bounce MX03 = Bounce(6, 10); // for most mechanical pushbuttons +Bounce MX04 = Bounce(7, 10); +Bounce MX05 = Bounce(9, 10); // if a button is too "sensitive" +Bounce MX06 = Bounce(10, 10); // you can increase this time. +Bounce MX07 = Bounce(17, 10); +Bounce MX08 = Bounce(16, 10); +Bounce MX09 = Bounce(15, 10); +Bounce MX10 = Bounce(14, 10); +Bounce MX11 = Bounce(12, 10); +Bounce MX12 = Bounce(11, 10); + +void setup() { + // Configure the pins for input mode with pullup resistors. + // The pushbuttons connect from each pin to ground. When + // the button is pressed, the pin reads LOW because the button + // shorts it to ground. When released, the pin reads HIGH + // because the pullup resistor connects to +5 volts inside + // the chip. + pinMode(4, INPUT_PULLUP); + pinMode(5, INPUT_PULLUP); + pinMode(6, INPUT_PULLUP); + pinMode(7, INPUT_PULLUP); + pinMode(9, INPUT_PULLUP); + pinMode(10, INPUT_PULLUP); + pinMode(17, INPUT_PULLUP); + pinMode(16, INPUT_PULLUP); + pinMode(15, INPUT_PULLUP); + pinMode(14, INPUT_PULLUP); + pinMode(12, INPUT_PULLUP); + pinMode(11, INPUT_PULLUP); + + pinMode(8, OUTPUT); // The virtual Ground Pin + digitalWrite(8, LOW); +} + +void loop() { + // Update all the buttons. There should not be any long + // delays in loop(), so this runs repetitively at a rate + // faster than the buttons could be pressed and released. + MX01.update(); + MX02.update(); + MX03.update(); + MX04.update(); + MX05.update(); + MX06.update(); + MX07.update(); + MX08.update(); + MX09.update(); + MX10.update(); + MX11.update(); + MX12.update(); + + // Check each button for "falling" edge. + // falling = high (not pressed - voltage from pullup resistor) + // to low (pressed - button connects pin to ground) + if (MX01.fallingEdge()) { + Keyboard.press(KEY_HOME); + Keyboard.release(KEY_HOME); + } + if (MX02.fallingEdge()) { + Keyboard.press(KEY_UP); + Keyboard.release(KEY_UP); + } + if (MX03.fallingEdge()) { + Keyboard.press(KEY_PAGE_UP); + Keyboard.release(KEY_PAGE_UP); + } + if (MX04.fallingEdge()) { + Keyboard.press(KEY_LEFT); + Keyboard.release(KEY_LEFT); + } + if (MX05.fallingEdge()) { + Keyboard.press(KEY_ESC); + Keyboard.release(KEY_ESC); + } + if (MX06.fallingEdge()) { + Keyboard.press(KEY_RIGHT); + Keyboard.release(KEY_RIGHT); + } + if (MX07.fallingEdge()) { + Keyboard.press(KEY_END); + Keyboard.release(KEY_END); + } + if (MX08.fallingEdge()) { + Keyboard.press(KEY_DOWN); + Keyboard.release(KEY_DOWN); + } + if (MX09.fallingEdge()) { + Keyboard.press(KEY_PAGE_DOWN); + Keyboard.release(KEY_PAGE_DOWN); + } + if (MX10.fallingEdge()) { + Keyboard.press(KEY_BACKSPACE); + Keyboard.release(KEY_BACKSPACE); + } + if (MX11.fallingEdge()) { + Keyboard.press(KEY_SPACE); + Keyboard.release(KEY_SPACE); + } + if (MX12.fallingEdge()) { + Keyboard.press(KEY_ENTER); + Keyboard.release(KEY_ENTER); + } +} diff --git a/polyandry/PolyPad_Teensy_3.5.ino b/polyandry/PolyPad_Teensy_3.5.ino new file mode 100644 index 0000000..f3dc5f7 --- /dev/null +++ b/polyandry/PolyPad_Teensy_3.5.ino @@ -0,0 +1,116 @@ +/* Buttons to USB Keyboard Example - Special Media Player Keys + You must select Keyboard from the "Tools > USB Type" menu + This example code is in the public domain. +*/ + +#include + +// Create Bounce objects for each button. The Bounce object +// automatically deals with contact chatter or "bounce", and +// it makes detecting changes very simple. +Bounce MX01 = Bounce(4, 10); +Bounce MX02 = Bounce(5, 10); // 10 ms debounce time is appropriate +Bounce MX03 = Bounce(6, 10); // for most mechanical pushbuttons +Bounce MX04 = Bounce(7, 10); +Bounce MX05 = Bounce(9, 10); // if a button is too "sensitive" +Bounce MX06 = Bounce(10, 10); // you can increase this time. +Bounce MX07 = Bounce(21, 10); +Bounce MX08 = Bounce(20, 10); +Bounce MX09 = Bounce(19, 10); +Bounce MX10 = Bounce(18, 10); +Bounce MX11 = Bounce(16, 10); +Bounce MX12 = Bounce(15, 10); + +void setup() { + // Configure the pins for input mode with pullup resistors. + // The pushbuttons connect from each pin to ground. When + // the button is pressed, the pin reads LOW because the button + // shorts it to ground. When released, the pin reads HIGH + // because the pullup resistor connects to +5 volts inside + // the chip. + pinMode(4, INPUT_PULLUP); + pinMode(5, INPUT_PULLUP); + pinMode(6, INPUT_PULLUP); + pinMode(7, INPUT_PULLUP); + pinMode(9, INPUT_PULLUP); + pinMode(10, INPUT_PULLUP); + pinMode(21, INPUT_PULLUP); + pinMode(20, INPUT_PULLUP); + pinMode(19, INPUT_PULLUP); + pinMode(18, INPUT_PULLUP); + pinMode(16, INPUT_PULLUP); + pinMode(15, INPUT_PULLUP); + + pinMode(8, OUTPUT); // The virtual Ground Pin + digitalWrite(8, LOW); +} + +void loop() { + // Update all the buttons. There should not be any long + // delays in loop(), so this runs repetitively at a rate + // faster than the buttons could be pressed and released. + MX01.update(); + MX02.update(); + MX03.update(); + MX04.update(); + MX05.update(); + MX06.update(); + MX07.update(); + MX08.update(); + MX09.update(); + MX10.update(); + MX11.update(); + MX12.update(); + + // Check each button for "falling" edge. + // falling = high (not pressed - voltage from pullup resistor) + // to low (pressed - button connects pin to ground) + if (MX01.fallingEdge()) { + Keyboard.press(KEY_HOME); + Keyboard.release(KEY_HOME); + } + if (MX02.fallingEdge()) { + Keyboard.press(KEY_UP); + Keyboard.release(KEY_UP); + } + if (MX03.fallingEdge()) { + Keyboard.press(KEY_PAGE_UP); + Keyboard.release(KEY_PAGE_UP); + } + if (MX04.fallingEdge()) { + Keyboard.press(KEY_LEFT); + Keyboard.release(KEY_LEFT); + } + if (MX05.fallingEdge()) { + Keyboard.press(KEY_ESC); + Keyboard.release(KEY_ESC); + } + if (MX06.fallingEdge()) { + Keyboard.press(KEY_RIGHT); + Keyboard.release(KEY_RIGHT); + } + if (MX07.fallingEdge()) { + Keyboard.press(KEY_END); + Keyboard.release(KEY_END); + } + if (MX08.fallingEdge()) { + Keyboard.press(KEY_DOWN); + Keyboard.release(KEY_DOWN); + } + if (MX09.fallingEdge()) { + Keyboard.press(KEY_PAGE_DOWN); + Keyboard.release(KEY_PAGE_DOWN); + } + if (MX10.fallingEdge()) { + Keyboard.press(KEY_BACKSPACE); + Keyboard.release(KEY_BACKSPACE); + } + if (MX11.fallingEdge()) { + Keyboard.press(KEY_SPACE); + Keyboard.release(KEY_SPACE); + } + if (MX12.fallingEdge()) { + Keyboard.press(KEY_ENTER); + Keyboard.release(KEY_ENTER); + } +}