Another example here but this time for the Teensy2.0 I had on hand. This example requires Teensyduino to be installed, then you choose Tools > USB Type > Keyboard + Mouse + Joystick
You will also need to add the Encoder and Keyboard libraries to Arduino.
See this thread for the Arduino + Rotary Encoder for volume and play / pause example
Using an Adafruit Rotary Encoder and a Teensy 2.0 you can simulate keyboard presses to make controlling certain aspects of OAP easy. This is done slightly differently to the arduino one as the keypresses are handled differently.
Parts
- Rotary Encoder (http://adafru.it/377)
- Teensy 2.0 (newer versions would be fine too)
Rotary Encoder has 3 pins on one side. I have pin 1 on the encoder connected to pin 6 on the Teensy, pin 2 on the encoder connected to GND and pin 3 on the encoder is connected to pin 5 on the Teensy.
For the button side I have one pin connected to pin 3 on the Teensy and the other in connected to GND on the Teensy.
You will also need to add the Encoder and Keyboard libraries to Arduino.
See this thread for the Arduino + Rotary Encoder for volume and play / pause example
Using an Adafruit Rotary Encoder and a Teensy 2.0 you can simulate keyboard presses to make controlling certain aspects of OAP easy. This is done slightly differently to the arduino one as the keypresses are handled differently.
Parts
- Rotary Encoder (http://adafru.it/377)
- Teensy 2.0 (newer versions would be fine too)
Rotary Encoder has 3 pins on one side. I have pin 1 on the encoder connected to pin 6 on the Teensy, pin 2 on the encoder connected to GND and pin 3 on the encoder is connected to pin 5 on the Teensy.
For the button side I have one pin connected to pin 3 on the Teensy and the other in connected to GND on the Teensy.
#include <Encoder.h>
#include "Keyboard.h"
Encoder myEnc(5, 6);
// 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.press(KEY_F8);
Keyboard.release(KEY_F8);
} else{
//Volume DOWN
Keyboard.press(KEY_F7);
Keyboard.release(KEY_F7);
}
oldPosition = newPosition;
}
if (playPause == LOW) {
//Play Pause Toggle
Keyboard.print("B");
delay(100);
}
delay(50);
}