NEW to DJTT! need some help with coding
Results 1 to 8 of 8
  1. #1
    Tech Convert
    Join Date
    Oct 2012
    Posts
    16

    Default NEW to DJTT! need some help with coding

    hello everyone,

    so ive been playing around with the teensy ++ 2.0 and just need help with programming the potentiometers. im still trying to learn as much as possible about programming as ive never done anything like this before. ive already gone through most of the tutorials on PJRC as it does cover potentiometers but it doesnt say how to program it with MIDI. ive already had success with programing a few push buttons and using it with serato scratch live.

    i have tried searching the forums and couldnt find the dirrect functions or code to use for potentiometers. ive also tried looking at Fuzzywobbles tutorial and code but i cant distinguish which code and function is for potentiometers

    i will be using these potentiometers for doing various scrolling through serato scratch live

    this is my circuit so far, i have the pots connected to PINS 38,39,40. i know that 10k ohm are recommended but i just had these in the garage and just wanted to do a quick test. if 100k is not compatible please let me know. please let me know if i have connected it incorrectly:



    my code so far looks like this and would just like to add 3 Potentiometers to the code. it just has push buttons on PINS 0-5 (just taken directly from the USB example in teensyduino):

    #include <Bounce.h>

    const int channel = 1;

    Bounce button0 = Bounce(0, 5);
    Bounce button1 = Bounce(1, 5);
    Bounce button2 = Bounce(2, 5);
    Bounce button3 = Bounce(3, 5);
    Bounce button4 = Bounce(4, 5);
    Bounce button5 = Bounce(5, 5);

    void setup() {

    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() {

    button0.update();
    button1.update();
    button2.update();
    button3.update();
    button4.update();
    button5.update();

    if (button0.fallingEdge()) {
    usbMIDI.sendNoteOn(60, 99, channel);
    }
    if (button1.fallingEdge()) {
    usbMIDI.sendNoteOn(61, 99, channel);
    }
    if (button2.fallingEdge()) {
    usbMIDI.sendNoteOn(62, 99, channel);
    }
    if (button3.fallingEdge()) {
    usbMIDI.sendNoteOn(63, 99, channel);
    }
    if (button4.fallingEdge()) {
    usbMIDI.sendNoteOn(64, 99, channel);
    }
    if (button5.fallingEdge()) {
    usbMIDI.sendNoteOn(65, 99, channel);
    }

    if (button0.risingEdge()) {
    usbMIDI.sendNoteOff(60, 0, channel);
    }
    if (button1.risingEdge()) {
    usbMIDI.sendNoteOff(61, 0, channel);
    }
    if (button2.risingEdge()) {
    usbMIDI.sendNoteOff(62, 0, channel);
    }
    if (button3.risingEdge()) {
    usbMIDI.sendNoteOff(63, 0, channel);
    }
    if (button4.risingEdge()) {
    usbMIDI.sendNoteOff(64, 0, channel);
    }
    if (button5.risingEdge()) {
    usbMIDI.sendNoteOff(65, 0, channel);
    }

    }

    Any help would be greatly appreciated, or if this has already been covered please direct me to a thread or website

    thanks all!
    Last edited by tekki; 12-26-2012 at 06:13 PM.

  2. #2
    Tech Convert
    Join Date
    Oct 2012
    Posts
    16

    Default

    any help guys? Still can't figure out how these pots are programmed.

  3. #3
    Tech Guru Nicky H's Avatar
    Join Date
    Jan 2009
    Location
    Leeds UK
    Posts
    2,485

    Default

    The code above is for buttons not pots mate.

    There's a nice midi tutorial here for a single pot - I used it originally and went from there:

    http://little-scale.blogspot.co.uk/2...ontroller.html

    Try getting 1 working as a USB midi device then you can add more when it's good.
    SC | MC

  4. #4
    Tech Convert
    Join Date
    Oct 2012
    Posts
    16

    Default

    Thank you very much Nicky H. That is exactly what I needed! Just gotta add it to my above code to go with my push buttons.

    Do you happen to have any reference for programming encoders also?

  5. #5
    Tech Guru Nicky H's Avatar
    Join Date
    Jan 2009
    Location
    Leeds UK
    Posts
    2,485
    SC | MC

  6. #6
    Tech Convert
    Join Date
    Oct 2012
    Posts
    16

    Default

    Hey guys. So I had success in programming the potentiometer to work with Serato. I am using this particular pot to scroll through the library. The problem I'm having now is that SSL is reading the potentiometer but when the potentiometer is turned all the way up the scrolling stops. So even though there are plenty more songs I can scroll through the knob cannot reach it because it doesnt continue to scroll. I am really aiming for the pot to work like this (@6:11)



    So im trying to program the pot to continue to scroll when it is fully cranked and stationary. Any help with the code? Or is it a specific type or potentiometer needed to do this action?

  7. #7
    DJTT Mapping Ninja Moderator Stewe's Avatar
    Join Date
    Aug 2010
    Location
    MIDI
    Posts
    7,493

    Default

    You need endless rotary encoder in relative mode.

  8. #8
    Newbie
    Join Date
    Dec 2012
    Posts
    3

    Default

    Quote Originally Posted by Scornil01 View Post
    So im trying to program the pot to continue to scroll when it is fully cranked and stationary. Any help with the code? Or is it a specific type or potentiometer needed to do this action?
    you cannot do this with a pot, you need a rotary encoder. It allows endless turn in either direction
    http://en.wikipedia.org/wiki/Rotary_...rotary_encoder
    http://playground.arduino.cc/Main/RotaryEncoders

    Or you can try the following: when pot is turned all the way left or right (analogRead should return 0 or 255 in this case), continue sending midi command to scroll up/down until the value changes. But I think that encoder would give a more convenient way for controlling library scroll

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •