Using an Adafruit Rotary Encoder and a compatible Arduino board you can simulate keyboard presses to make controlling certain aspects of OAP easy.
Parts
- Rotary Encoder (http://adafru.it/377)
- Compatible arduino (https://www.arduino.cc/reference/en/lang.../keyboard/)
You will also need to add the Encoder and Keyboard libraries to Arduino.
I'm using a Leonardo to test but will likely move to a Teensy board or similar. You can apparently do this with an Adafruit Pro Trinket however I only have the normal Trinket which i can confirm wont work.
Rotary Encoder has 3 pins on one side. I have pin 1 on the encoder connected to pin 2 on the arduino, pin 2 on the encoder connected to GND and pin 3 on the encoder is connected to pin 1 on the arduino.
For the button side I have one pin connected to pin 3 on the arduino and the other in connected to GND on the arduino.
Here is the code:
Biggest issue is that you would have to remove the arduino to reupload code to change what keypresses it emulated. It would be great if there was a Play / Pause button instead of two seperate ones.. You could however program it to remember the last push and change what it sends to get both buttons working.
--edit-- I found the play pause button and it was also mentioned below, code has been updated to reflect.
Parts
- Rotary Encoder (http://adafru.it/377)
- Compatible arduino (https://www.arduino.cc/reference/en/lang.../keyboard/)
You will also need to add the Encoder and Keyboard libraries to Arduino.
I'm using a Leonardo to test but will likely move to a Teensy board or similar. You can apparently do this with an Adafruit Pro Trinket however I only have the normal Trinket which i can confirm wont work.
Rotary Encoder has 3 pins on one side. I have pin 1 on the encoder connected to pin 2 on the arduino, pin 2 on the encoder connected to GND and pin 3 on the encoder is connected to pin 1 on the arduino.
For the button side I have one pin connected to pin 3 on the arduino and the other in connected to GND on the arduino.
Here is the code:
#include <Encoder.h>
#include "Keyboard.h"
Encoder myEnc(1, 2);
// avoid using pins with LEDs attached
void setup() {
Serial.begin(9600);
pinMode(3, INPUT_PULLUP);
Keyboard.begin();
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc.read();
int playPause= digitalRead(3);
if (newPosition != oldPosition) {
if (newPosition > oldPosition){
//Volume UP
Keyboard.write(KEY_F8);
} else{
//Volume DOWN
Keyboard.write(KEY_F7);
}
oldPosition = newPosition;
}
if (playPause== LOW) {
//Next track
Keyboard.print("B");
delay(100);
}
delay(50);
}
Biggest issue is that you would have to remove the arduino to reupload code to change what keypresses it emulated. It would be great if there was a Play / Pause button instead of two seperate ones.. You could however program it to remember the last push and change what it sends to get both buttons working.
--edit-- I found the play pause button and it was also mentioned below, code has been updated to reflect.