Unsigned binary multiplication varying result

Hi,

I am working on a little project to display in 2x 7 segment display the multiplication of two 4-bit numbers. The inputs are from 10-13 and A0-A3. I am controlling the inputs with a DIP switch whereby the 5 V is provided from the Arduino.

My question is, why the result is varying each time I press the push button (I used it to indicate start the calculation). Sometimes gives to me the correct answer but sometimes not... So maybe I need to connect a pull-up/down or what?

I tried to use the built-in resistor that is on the Arduino with not success... The output using this method is like all of the bit switch position are turned on.

I tried using physical pull down resistors (10k) and it seems that worked.

I am wondering why the built in pull up resistor of the Arduino didn't.

Please post your code so we can have a look..

SpcCode:
I tried using physical pull down resistors (10k) and it seems that worked.

I am wondering why the built in pull up resistor of the Arduino didn't.

Well, pull-down and pull-up do opposite things. If you connected the switch to "the 5 V is provided from the Arduino" as you said, and you had pull-ups enabled, then the pin will always be 5V, whether or not you push the switch.

But if you had pull-down resistors, then the switch is now 0V when not pressed, and 5V when pressed.

The pull-ups would have worked if you had connected the switches to ground, then the normal state would be 5V (the pull-up) and 0V when you pressed it. Of course you have to reverse the logic to test for a 0-bit rather than a 1-bit if you do it this way.

Thanks!