NEW to DJTT! need some help with coding

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!

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

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:

Try getting 1 working as a USB midi device then you can add more when it’s good.

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?

No probs, I started from this:

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?

You need endless rotary encoder in relative mode.

you cannot do this with a pot, you need a rotary encoder. It allows endless turn in either direction

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