ElectroDFW:
As a hardware technician just getting started with an Uno, 95% of those questions are Greek to me.
37. What does a pull down resistor do to a floating input pin?
Figure-1: Explaining the importance of internal pull-up, external pull-up, and external pull-down.
Consider bit-2 IO line of Port-D Register. When this IO line is configured to work as an input line, it takes over the symbolic name -- PIND2. The external button (K1) can be connected with this input line via DPin-2 (Digital Pin Connector) of Arduino UNO.
In Fig-1, there are there are three resistors (R1, R2, and Rp) around DPin-2. R1 is an external pull-down resistor placed by the user; R2 is an external pull-up resistor placed by the user; Rp is an internal pull-up resistor placed by the designer of the ATmega329P Microcontroller. The resistors are associated with switches by which they could be connected or disconnected.
When all the switches are at opened condition, the input line assumes no definite voltage level. The voltage levle of DPin-2 could be 0V or 5V or in between or all the time changing. This is known as floating condition of the input line.
The insertion of the external pull-down resistor (R1) will propagate 0V from the GND-pin onto DPin-2; now, the DPin-2 is no more at the floating state. When button K1 is closed, the DPin-2 will assume LH state.
The insertion of the external pull-up resistor (R2) will propagate 5V from the 5V-pin onto DPin-2; now, the DPin-2 is no more at the floating state. At this condition, the 5V terminal of button K1 has to be connected to GND. When button K1 is closed, the DPin-2 will assume LL state.
The insertion of the internal pull-up resistor (Rp) will propagate 5V from the 5V-pin onto DPin-2; now, the DPin-2 is no more at the floating state. At this condition, the 5V terminal of button K1 has to be connected to GND. When button K1 is closed, the DPin-2 will assume LL state.
34. What does INPUT_PULLUP do in this line of code? pinMode(2, INPUT_PULLUP);
The execution of the pinMode(2, INPUT_PULLUP); function configures DPin-2 to work as input line along with the internal pull-up resistor connected. If we don't to connect the internal pull-up (sometimes, we don't need it because of very high value; it does not work for me with external interrupt lines), we execute the instruction pinMode(2, INPUT);. In this case, we have to connect the external pull-up or pull-down as per requirement/convenience to avoid floating condition of the input line.