??Help about Rotery encoder? (I am making Music Rhythm Sampler from laptop to singni

Status
Not open for further replies.

charnjit

Active member
IMG_0592.jpg

hello sir,
Teensy is controller of my music sampler. Can i connect directly 3 legs rotary encoder to Pin 2, Pin 3 & GND..??? i want to use
rotery encoder (3 legs) instead of buttons conected to pin 2, pin 3.
i don't know, how to add rotery encoder in codes given below.


Code:
[code]
#include <Bounce.h>

Bounce pitchup = Bounce(0, 10);
Bounce pitchdown = Bounce(1, 10);
Bounce tempoup = Bounce(2, 10);
Bounce tempodown = Bounce(3, 10);
Bounce keytap = Bounce(4, 10);
Bounce leytap = Bounce(5, 10);


void setup() {
  Mouse.screenSize(1366, 768);  // configure screen size
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
}

void loop() {
  pitchup.update();
  pitchdown.update();
  tempoup.update();
  tempodown.update();
  keytap.update();
  leytap.update();
 if (pitchup.fallingEdge()) {
    Mouse.moveTo(357, 36);      // point to pixel at (357, 36)
    Mouse.set_buttons(1, 0, 0);  // hold left button
    Mouse.moveTo(357, 31);
    Mouse.set_buttons(0, 0, 0);  // hold left button
  }
  if (pitchdown.fallingEdge()) {
    Mouse.moveTo(357, 36);      // point to pixel at (357, 36)
    Mouse.set_buttons(1, 0, 0);  // hold left button
    Mouse.moveTo(357, 41);
    Mouse.set_buttons(0, 0, 0);  // hold left button
    }
  if (tempoup.fallingEdge()) {
    Mouse.moveTo(512, 54);       // point to pixel at 512, 54
    Mouse.scroll(+1);           // turn scroll wheel upward 1 step
    Mouse.moveTo(345, 94);      
  }
  if (tempodown.fallingEdge()) {
    Mouse.moveTo(512, 54);      // point to pixel at 512, 54
    Mouse.scroll(-1);           // turn scroll wheel downward 1 step
    Mouse.moveTo(345, 94);
  }

    if (keytap.fallingEdge()) {
    Keyboard.set_key1(KEY_F6);  // Press F6
    Keyboard.send_now();
    Keyboard.set_key1(0);       //Release F6
    Keyboard.send_now();
    }
  if (leytap.fallingEdge()) {
    Keyboard.set_modifier(MODIFIERKEY_CTRL);  //Press ctrl  key
    Keyboard.send_now();
    Keyboard.set_key1(KEY_F5);      //Press  F5
    Keyboard.send_now(); 
    Keyboard.set_modifier(0);    // Release  ctrl key
    Keyboard.set_key1(0);       // Release F5
    Keyboard.send_now();
    }
  
  }
[/CODE]

please make changes in these code to add rotery encoder to pin 2, pin 3.
After complete my project(Diy Rhythm Sampler at home from your laptop to perfom live singing program without musicians),
My project is not personal, it is for you all of you.
I will full tutorial of this on this Forum. so please help me
 
You can make the changes by yourself after you will have understood that you can not use encoder and button on the same pin. You will need to include the encoder library which comes with Teensyduino and which contains enough examples to learn how to use it.
 
Sorry,,,,,sir ,,,, teensyduino has 3 examples of encoder . But there is not any helpful example of rotary encoder , I was searching for a example , inwhich it should be told that " how to send a keyboard or mouse inputs through rotating rotary encoder(3legs) clockwise & anti-clockwise. Where can I found idea or learnt code for rotary encoder to send usb mouse / keyboard inputs Like given in my previous post????????????
 
What hinders you from reading the encoder value after an up or down movement into a variable and then write code which acts depending the value of that variable?

Why do you start such a project if you can't do that simple coding? Perhaps start with something simpler, for example make some LEDs blink first before making more complex things? Why not first exercise with an encoder which dims a LED?
 
Sorry sir I am not familiar with arduio . I am a carpenter & music keyboard player only . I recently learnt above code from examples. Now , in encoder examples I did not saw 2 different result which are be get on moving encoder clockwise & anti-clock wise. If you have example , which is related to my project , please post here or link. I shall be highly thankful you ,,,
 
If the encoder is wired right, example code should be printing a value that counts up with one direction and down in the other. So you write code that checks of oldValue<newValue and does stuff and also if oldvalue>newValue sends the reverse. If the values were the same (no encoder motion) then nothing will happen.
 
Status
Not open for further replies.
Back
Top