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.
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.
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.
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;
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!
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?
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.