Arduino Arpegiator module

I havent seen the full code yet, just kinda stumbled across the thread sorry!

But you would specify this wherever you specify the MODE of the pin, which is in the setup function normally. The for loop you posted is just running through and setting modes for a bunch of pins at once. If these are the pins you need to have internal pull up resistors enabled (2-13), then this is the code to use:

for (int i = 2; i <= 13; i++) {
    pinMode(i,INPUT_PULLUP);
}

According to the diag, it looks like those are indeed the pins with the resistors so this code should do you.

1 Like

Thanks for your help!

Made some changes and it compiles ok, I’ll report once built

2 Likes

Hi!
Yes, you can indeed replace the mode selector switches A6 and A7 by just one potentiometer!
There is a

enum eMode mode;

at line 63.

The enum different values are specified at the top of the code.

enum eMode {
up = 0,
down,
upAndDown,
arpRandom
};

Just check the analog input value, and feed the variable with the corresponding value …

int analogValue = analogRead(X) > 500; //X is the analog input you choose
analogValue = round((analogValue/1023.)*4.);

switch(analogValue) {
case 0 : mode = up; break;
case 1 : mode = down; break;
case 2 : mode = upDown; break;
case 3 : mode = random; break;

}

You could even cast analogValue into an enum, that should work …

2 Likes

Hi,

int analogValue = analogRead(X) > 500;
This gives you a boolean value, not an analog value (a copy/paste from another piece of code made too rapidly ?).
Should probably be :
int analogValue = analogRead(X);

And
analogValue = round((analogValue/1023.)*4.);
works but it is somewhat overkill to use slow floating point computation for this when :
analogValue = (analogValue+127) >> 8;
does the job nicely.

Should probably be :
int analogValue = analogRead(X);

Of course!! Sorry, made it too fast!

analogValue = (analogValue+127) >> 8;
does the job nicely.

I’m never confident with bit shifting :smiley: That’s something that I should use more, but always afraid of it because not easily readable.

1 Like

You also could use a 4-position rotary switch, wired to Vcc and ground at the two ends and with equal resistors between the terminals — then it becomes a sort of discrete-valued potentiometer. Read it basically the same way. More complicated than a pot but nicer to use.

3 Likes

thanks for you inputs guys!

being a bit crude at this I went down this route:

 bool modeSwitch = analogRead(2);

   enum eMode mode;
if (modeSwitch >=0 & modeSwitch <=255) {
    mode = upAndDown;  
} 
else if (modeSwitch >=256 & modeSwitch <=511) {
    mode = up;
} 
else if (modeSwitch >=512 & modeSwitch <=766) {
    mode = down;
} 
else {
    mode = arpRandom;
}

Do you think is going to work?
thanks

1 Like

That line won’t work, it’ll assign a value of true or false to modeSwitch. You need int, not bool.

Other than that it looks fine to me, and easier to understand than some other approaches. But you could dispense with the curlies, and you can simplify the conditionals:

int modeSwitch = analogRead(2);

enum eMode mode;
if (modeSwitch <=255)
  mode = upAndDown;  
else if (modeSwitch <=511)
  mode = up;
else if (modeSwitch <=766) 
  mode = down;
else
  mode = arpRandom;
2 Likes

Many many thanks!
I will update accordingly

2 Likes

Well my boards are in the UK, probably due a customs charge. may have them by the weekend.

1 Like

4 Likes

Boards have final arrived for the Proto V1

There is a mistake with the first note switch on the PCB, in all the moving arround it’s ended up out of place. There’s enough space just!

My “Mode” Legends have come out ok…

4 Likes

Wow, that really looks very nice! I love the Stranger Things themed panel.

This one is high on my list of modules I want to make.

1 Like

Thanks,

My son dragged me to watch “Stranger Things” and i was instantly hooked just by the music… Although the Score writes did not use an arpegiator for the theme music. Between designing the board and it’s arrival I have learned that it’s easy to play, and getting some nice vintage tones out of my K2 MS-20 Clone, so will be fun to see if I can replicate it with this module and the rest of the modular!

4 Likes

:wink:

5 Likes

I think i probably watched that back in March with no idea what it related too… Awesome!

4 Likes

I made this! It’s a good design, I’m happy with it. I’m building a ‘tardis control panel*’ synth in a very haphazard way, learning as I go.

*actually a cake stand

The tardis is coming along pic.twitter.com/XYxbaE39RH

— Bone Music (@bluepuffinmedia) February 2, 2021
2 Likes

Well learned two things today…

  1. you can’t use (INPUT PULLUP) on digital pin 13, due to the onbaord LED and resistor.
  2. you can’t use A6 or A7 with INPUT PULLUP either!
5 Likes

Hey! I started a new module today (a random trigger) and tested your double 1N5817 solution! Works great!
But I need to put also a pulldown resistor (something like 100k) between the input and ground, otherwise the state of the input is always HIGH.
Do you think it is a correct implementation?

1bacff9da5e9730456d5c1688f079c5b40a405ad (1)

1 Like

Hi all, first post here so sorry if I should open a new thread for this question.
I’ve built this arpeggiator - works great apart from the fact that I wired the switches wrong(pin 2 is the first switch and 13 the last switch.) I am horrific at programming/Arduino etc and wondered if there was a simple way to reverse the pins in the code as I really don’t want to have to rewire everything. I had a quick look and think I need to change something in the for (int i = 2; i <= 13; i++) loop but I’m completely out of my depth here so any help is gladly appreciated.

Thanks in advance!

1 Like