Pullup or Pulldown

I am struggling with the concept of pullup and pulldown resistors. The attached 'Traffic_Control' exercise runs fine on the circuit in the 'Traffic_Control_Schematic', but then I find an identical exercise in a textbook with the other schematic. I used pulldown resistors, Boxall uses pullup (I think that is the right way round).

I haven't tried Boxall's circuit (but I will assume it works) but I am left with the question, "Is there a right way and a wrong way?" Assuming both work, should I use one style rather than the other?

Even more confusing, how is it that both work? How is it that I could use either?

Thanks

Traffic_Control_Redacted.ino (3.49 KB)

Traffic Control Schematic - Redacted.pdf (15.5 KB)

Boxall Schematic.pdf (244 KB)

In first order, it really does not matter (though both of your PDFs pull down, don't they?).

I heart that with traditional TTL logic, pulling an input to LOW took more current than to pull it to HIGH, hence pullups are more common. (Maybe someone can explain, are there usually PNP transistor bases on inputs?)
You get them for free in the Arduino, since they are integrated and switchable in the AVR. So with a pullup, you can just attach a switch und do the rest in software.
Also, ground may be better available at the switch than 5V. Usually, everything is filled with a ground plane anyway, you don't have to break it with a 5/3.3V trace to one switch terminal.

It comes down to what's conveniently available on the PCB. On breadboard I'd just use internal pull up resistors so I don't need to deal with external resistors. The code will need to be set to account for any changes.

ie if the pull down is used with switch to 5v, the code runs when the pin goes high. If you changed to pull up resistors and switch to ground, the code would have to be changed to run when the pin goes low.

Simple to change either way.

Logic circuitry can be "active low" or "active high" as you choose - a signal can represent true/false either
way round so long as you use it consistently.

For switching the convenience of switching to GND is often the deciding factor as you have an otherwise
unconstrained choice

Thanks for that, ElCaron, but I am not quite with you.

ElCaron:
In first order, it really does not matter (though both of your PDFs pull down, don't they?).

No. If I have this the right way round, Boxall uses pullup on the lEDs and pulldown on the switches. I use pulldown all over.

ElCaron:
I heart that with traditional TTL logic, pulling an input to LOW took more current than to pull it to HIGH, hence pullups are more common. ... You get them for free in the Arduino, since they are integrated and switchable in the AVR. So with a pullup, you can just attach a switch und do the rest in software.

Am I to understand that each output pin on my UNO has a built-in pullup resistor? From there, am I to take it that I don't need external pullup when driving an LED. I seem to remember my first excursion into LED land (not all that long ago) when the LEDs would freeze ON and the solution was pulldown resistors. That's why I have installed them since.

ElCaron:
Also, ground may be better available at the switch than 5V. Usually, everything is filled with a ground plane anyway, you don't have to break it with a 5/3.3V trace to one switch terminal.

I don't understand what you are saying here.

Thanks for that wilykat, but I'm a little confused. You say:

wilykat:
On breadboard I'd just use internal pull up resistors so I don't need to deal with external resistors.

Then go on to say:

wilykat:
... if the pull down is used with switch to 5v, the code runs when the pin goes high.

Running the code when I push the button is the desired effect. Therefore, you are saying, I should use pulldown (which I did) when you have just said you use 'internal pullup'.

I go round in circles and get confuseder and confuseder. :frowning:

I am sure you are saying something, MarkT, but I can't figure out just what.

MarkT:
Logic circuitry can be "active low" or "active high" as you choose - a signal can represent true/false either
way round so long as you use it consistently.

I appreciate the point about being consistent.

MarkT:
For switching the convenience of switching to GND is often the deciding factor as you have an otherwise
unconstrained choice

You speak of switching to GND - what else would you switch to?

Please bear in mind that this is a whole new world to me and I just don't understand what you are getting at.

Thanks

This is my attempt at trying to explain this topic for beginners:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

You speak of switching to GND - what else would you switch to?

Switching to 5V, like you do when you use a pull down resistor.

vagulus:
Thanks for that, ElCaron, but I am not quite with you.

vagulus:
No. If I have this the right way round, Boxall uses pullup on the lEDs and pulldown on the switches. I use pulldown all over.

Sorry, I have only looked at the switches. My answer also essentially just references switch applications.

vagulus:
Am I to understand that each output pin on my UNO has a built-in pullup resistor?

Yes, but it will only be strong enough to switch logic with trace capacitance that you expect on a PCB and only if it is not too fast. It will not be strong enough to provide enough current for an LED.

I don't understand what you are saying here.

When you design a PCB, you connect one switch pin to the Arduino. The other side needs to go either to GND or to VCC. GND tends to be ALL OVER THE PLACE, so it is not hard to connect to it. VCC may be far away.
The pull resistor "direction" depends on what you choose. It will be in the area of the MCU, where VCC is certainly available, or even built in. So in general, routing a PCB will often be easier if you choose a pullup for a switch.

For the LED, it really depends on the situation. In most cases, LEDs with pull resistors are a secondary indicator for another circuit. (Like TX/RX on the Arduino). The the choice entirely depends on when you want the LED to light up.

Thanks folks. I am (slowly) getting the idea. A bit more practical work will probably clarify the issue.