Simple program help for beginner.

So I got an Arduino to get a basic understanding of programming and in the end I hope to move onto C. I have an Arduino Uno and all I want to do is make it count in binary and output this in 8 bits paralleled on it's output. I would also like 3 inputs for counting up, down and then sending all outputs high. I have very good analogue electronics knowledge but programming is totally new to me.

What I want from this system is volume control. The micro will drive 8 relays (with buffered outputs) with form a resistive ladder to attenuate the input signal going to my amplifier. So what will happen is the first relay will either send the signal through a potential divider of -1dB or bypass it the second will be -2dB and bypass the third -4dB and so on the 8th relay will be mute which will ground the signal.

I have no idea where to start whatsoever at all. I hope my brief makes sense could someone help me out?

Thanks
Boscoe

If you have no programming experience then what you need to do is start small and work your way up. Read through the examples in the learning section of this site and try to get LEDs blinking, then work a button in, then two buttons, then a potentiometer, etc. Jumping into a large project fromt the start is just silly.

As for counting in binary there is some info in the shiftout example which might give you insight in how to do so with an Arduino.

That sounds like you'll have lots of relays clattering away, and all the circuits to power and control them. Have you considered using a digital potentiometer instead?

PeterH:
That sounds like you'll have lots of relays clattering away, and all the circuits to power and control them. Have you considered using a digital potentiometer instead?

It's the best solution for high performance audio, there are dedicated volume chips the figures look good at 1KHz but aren't that great higher up. This volume control will have zero distortion in theory.

Quick5pnt0:
If you have no programming experience then what you need to do is start small and work your way up. Read through the examples in the learning section of this site and try to get LEDs blinking, then work a button in, then two buttons, then a potentiometer, etc. Jumping into a large project fromt the start is just silly.

As for counting in binary there is some info in the shiftout example which might give you insight in how to do so with an Arduino.

Thanks will do.

boscoe:
I have an Arduino Uno and all I want to do is make it count in binary and output this in 8 bits paralleled on it's output.

Here's a code snippet for sequentially outputting 4 bits (0 - 15) to get you started:

     for (i=0; i<16; i++){
      //Disable output
        digitalWrite(12,HIGH)
      //set up LSB first
        digitalWrite(8, i&1);
     //shift right = divide by 2
        digitalWrite(9, (i/2)&1);
     //shift right twice =divide by 4
        digitalWrite(10, (i/4)&1);
      //shift right four times =divide by 8 for MSB
        digitalWrite(11, (i/8) &1);
     //enable output
        digitalWrite(12,LOW)
    }

Or, more intuitively

 digitalWrite(8, i & 1);
        digitalWrite(9, i & 2);
        digitalWrite(10, i & 4);
        digitalWrite(11, i & 8);
     //enable output
        digitalWrite(12,LOW)

AWOL:
Or, more intuitively

 digitalWrite(8, i & 1);

digitalWrite(9, i & 2);
        digitalWrite(10, i & 4);
        digitalWrite(11, i & 8);
     //enable output
        digitalWrite(12,LOW)

Thanks for that, AWOL.
I had assumed that only a 1 is equivalent to HIGH, whereas it appears from your code that any value greater than 0 is read as HIGH.

it appears from your code that any value greater than 0 is read as HIGH.

Almost - in C, the convention is that any non-zero value, positive or negative, is interpreted as "true".

AWOL:

it appears from your code that any value greater than 0 is read as HIGH.

Almost - in C, the convention is that any non-zero value, positive or negative, is interpreted as "true".

I was thinking solely of 'unsigned ints', duh! Thanks again.

I know you are just starting out, but I would suggest you study C++ and not C since the Arduino platform is based on it. I recently purchased a C++ reference book that has been quite helpful. In addition, this site is very good:
http://www.learncpp.com

But before you go into C++ too deep, I agree with what has been said. Focus on the examples provided on the Arduino IDE (interractive design environment). They have helped me a bunch.