How to determine my memory needs

Hello guys,

I've setup my first project (a midi sequencer), wrote the code and made a list of my needs.
But now that it's time to buy an arduino and the components, I am a bit lost as it's my first electronic project.

Here is all I know about the sequencer:

So, my question is: which arduino should I buy considered the number of pins I need (I have difficulties to determine the quantity of pins I need, if they have to be pull-up or not, or magic, or if the shield is compatible with all of this etc...) ?
More generally : when I don't have an Arduino next to me, how do I know my code will fill into the flash? (and all subsidiaries questions)

Maybe the questions are asked pretty badly,
don't hesitate to be verbose :wink:
Thank you !

or magic

?

the quantity of pins I need, if they have to be pull-up or not

That depends on the code. If it is ACTIVE LOW, then you would want a 10k pullup to keep it high when it is not active.
The same goes for ACTIVE HIGH. You would want a 10k pulldown resistor to keep it low when not active.
The buttons should have pullup/dwn resistors on the arduino I/O line that connects to them and 1k pullup/dwn on the side going to +5V or GND. That prevents direct shorting to GND of an I/O line if it has not been properly setup as in INPUT (which can tolerate a direct short to GND). You may be advised to use the arduino software pullup feature. I don't use it because I like to be able to tell how it is setup by glancing at the circuit as opposed to going through 1000 lines of code.

2 infinite encoders

?
Absolute or incremental ?

I use the input pullups all the time.
If the Tab feature in the IDE is used, then the code can easily be broken up into Notes, pre-setup, setup loop, loop1, loop2, to make a more easily editable/reviewable file.

I tried to use the Tab feature but all the tutorial pages I found said to click on the RIGHT pointing arrow but that's the Upload button. I checked all the menus and didn't find anything that mentioned tabs.
So how do you open a new tab ?

Nevermind, I found it. It's the drop down menu button just below the Search Magnifying glass.
I didn't see it's location described that way anywhere.
This tutorial shows I right facing arrow but the instructions are correct.

This one has a screenshot that shows the right facing arrow which could only mean it used to be that way previously but has since been changed to the down facing arrow in the same location.
http://letsmakerobots.com/node/28305

In 1.0.5 it's downpointing.

Thank you for the answers.

That depends on the code. If it is ACTIVE LOW, then you would want a 10k pullup to keep it high when it is not active.
The same goes for ACTIVE HIGH. You would want a 10k pulldown resistor to keep it low when not active.

I read a bit about that and it seems to me that it is needed everytime I set up a led, am I getting that wrong ?
What I need is pretty straightforward I believe: if I'm in "that" mode, I want "this" led to be HIGH, in other case...
Or: if I'm reading a midi string and am at index 0, I want the first led to be HIGH and others low.

What I finally get from this part of the answer is that it doesn't really matter how many pull-up resistors my arduino has because I can set them by myself. So, to choose the good Arduino, I just need to count the pins it has.

Here is the simplest example I could find:

if (start_button.update()){                                    //  Tells me if the button status has changed. Don't need to test his value here.                    
        if (running == 0 || running == -1){                // if sequencer was off (this is the way I test the previous value of my button)
            digitalWrite(startled, HIGH);                      // keeps it HIGH until the next  "start_button.update()"
            digitalWrite(endled, LOW);
            running = 1;
        }
        else{                                                            //if sequencer was on
            digitalWrite(startled, LOW);
            running = 0;
        }
    }

Now I'm confused or this is wrong...

Right, that would be 2 LEDs; since these are driven by output pins, pullup/pulldown resistors are not needed, they are only used with input pins (or in the special case of I2C, where the outputs can only drive low, and the resistor is the only means to bring the line high). LEDs do need current limit resistors between the arduino pin and the LED anode (turn LED on when outout is high) with cathode to Gnd; or between the arduino and the LED cathode (turn LED on when output is low) with anode to +5. A value of 220 ohm, 270 ohm, 330 ohm, is pretty good.

Pullups/dwns are for Inputs, nothing at all to do with Leds which are driven by Outputs and have SERIES resistors TO LIMIT CURRENT so
you won't blow the led the instant you turn it on. They are unforgiving...

Ok, I think I understand that.

So, the leds have nothing to do with the pull-up resistors as their pins are outputs.

But my start_button has to be connected either to a resistor or VCC, so its pin needs to be in pull-up mode.
So, if I modify a bit my previous code, it gives :

int startbutton = 2; //start_button is connected to pin 2 for instance
int running = 0;
Bounce start_button;

void setup(void)
{
pinMode(startled, OUTPUT);

pinMode(startbutton, INPUT);
digitalWrite(start_button, HIGH); //active pull up resistor. Would be more logical to active a pull down.

start_button.attach(startbutton); //creating bounce object.
start_button.interval(5);
}

void loop(void)
{
if (digitalRead(start_button) == LOW) { //means the button has been pressed
if (running == 0 || running == -1){
digitalWrite(startled, HIGH);
running = 1;
}
else{ // the pull-up resistor remains HIGH
digitalWrite(startled, LOW);
running = 0;
}
}

/* which is equal to that code:
if (start_button.update()){
if (running == 0 || running == -1){
digitalWrite(startled, HIGH);
running = 1;
}
else{
digitalWrite(startled, LOW);
running = 0;
}
}
*/
}

Are they fully equivalent ?

The button has two connections. The side connected to the arduino input pin (with an internal or external pullup) and the side that connects to GND (if the signal is active LOW) or +5V (if the signal is active HIGH) . Either way, it is better to include a 1k resistor in series for this connection to protect the I/O pin from damage if you inadvertently load the wrong code and configure the pin as an OUTPUT instead of an INPUT. If you think you will never do that, then you can omit the 1k series resistor, but if you do that and short that output to gnd, you could damage the pin and the only way to repair it is replace the processor chip, which means burn a bootloader or buy a chip with the bootloader. Do you want to do that ? Resistors are a lot cheaper than processor chips.

Ok, I note that information and will make sure to protect the pins and chip !

Do you know how many pull-up resistors does Arduino have ? I can't find the answer on google...
As I'll need between 10 and 12 buttons, plus lots of leds, should I go for an arduino mega ?

Read this