# NEW to DJTT! need some help with coding

**URL:** <https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756>\
**Category:** Hardware: Controllers, Mods and Gear\
**Tags:** serato-sl, code, teensy, potentiometer\
**Created:** [December 14, 2012, 11:57pm UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756 "2012-12-14T23:57:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scornil01](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Scornil01](https://forum.djtechtools.com/u/Scornil01)\
**Post date:** [December 14, 2012, 11:57pm UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/1 "2012-12-14T23:57:47Z")

</div>

**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:

 ![IMG_0265.jpg](https://us1.discourse-cdn.com/flex001/uploads/techtools/original/3X/1/f/1f6d8fbb4c897ad1b2d185893eaac0e1df000491.jpeg)

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!

---

<div class="post-metadata">

**Author:** ![Scornil01](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Scornil01](https://forum.djtechtools.com/u/Scornil01)\
**Post date:** [December 21, 2012, 3:22pm UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/2 "2012-12-21T15:22:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nicky\_H](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.djtechtools.com/nicky_h/32/109_2.png) [@Nicky\_H](https://forum.djtechtools.com/u/Nicky_H)\
**Post date:** [December 21, 2012, 4:36pm UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/3 "2012-12-21T16:36:18Z")

</div>

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:

> **[A Very Simple DIY USB MIDI Controller](http://little-scale.blogspot.com/2012/10/a-very-simple-diy-usb-midi-controller.html)**
>
> Overview The aim of this post is as a starting point for making your own DIY MIDI controller. Although many MIDI controllers can be purchas...

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

---

<div class="post-metadata">

**Author:** ![Scornil01](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Scornil01](https://forum.djtechtools.com/u/Scornil01)\
**Post date:** [December 22, 2012, 9:28am UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/4 "2012-12-22T09:28:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Nicky\_H](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.djtechtools.com/nicky_h/32/109_2.png) [@Nicky\_H](https://forum.djtechtools.com/u/Nicky_H)\
**Post date:** [December 23, 2012, 8:30pm UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/5 "2012-12-23T20:30:38Z")

</div>

No probs, I started from this:

> <https://github.com/ghztomash/MIDI-Rotary-Encoder/blob/master/newRotaryEncoder_MIDI.ino>

---

<div class="post-metadata">

**Author:** ![Scornil01](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Scornil01](https://forum.djtechtools.com/u/Scornil01)\
**Post date:** [December 26, 2012, 7:00pm UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/6 "2012-12-26T19:00:50Z")

</div>

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)

[![](https://us1.discourse-cdn.com/flex001/uploads/techtools/original/3X/1/2/12b908908ebd77724b5cf96ea64890223f0c3626.jpeg "How to setup and use a MIDI controller in Serato Scratch LIVE (DDM4000 response)") ](https://www.youtube.com/watch?v=NwHY0DgZhPI)

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?

---

<div class="post-metadata">

**Author:** ![Stewe](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.djtechtools.com/stewe/32/14607_2.png) [@Stewe](https://forum.djtechtools.com/u/Stewe)\
**Post date:** [December 27, 2012, 2:27am UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/7 "2012-12-27T02:27:43Z")

</div>

You need endless rotary encoder in relative mode.

---

<div class="post-metadata">

**Author:** ![mrvn](https://avatars.discourse-cdn.com/v4/letter/m/f07891/32.png) [@mrvn](https://forum.djtechtools.com/u/mrvn)\
**Post date:** [December 27, 2012, 6:23am UTC](https://forum.djtechtools.com/t/new-to-djtt-need-some-help-with-coding/50756/8 "2012-12-27T06:23:02Z")

</div>

> [@Scornil01](#):
>
> 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

> **[Rotary encoder](https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_rotary_encoder)**
>
> A rotary encoder, also called a shaft encoder, is an electro-mechanical device that converts the angular position or motion of a shaft or axle to analog or digital output signals.
> There are two main types of rotary encoder: absolute and incremental. The output of an absolute encoder indicates the current shaft position, making it an angle transducer. The output of an incremental encoder provides information about the motion of the shaft, which typically is processed elsewhere into information s...

> **[Arduino Playground - HomePage](https://playground.arduino.cc/)**

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
