Using a pull-down resistor

So the question is, how are we going to get three wires into a device with two leads? We're going to use what's called a pull-down resistor to tie an input to the side of the button not connected to power. When the button is pressed, electricity will flow through the resistor into the signal wire, and we'll use a digital input pin on the Pi to detect that as a button press.

To do this, wire one side of your button to a 5V power pin on the cobbler. On the other side, place a 10K ohm resistor that bridges to another row of the breadboard, and in that row place a wire to bridge to a GPIO pin on the cobbler. Then, in the second row of the button, below the resistor, place a wire bridging to a GND pin on the cobbler.

The resistor prevents the Pi from shorting when the button is pressed, which will cause your Pi to temporarily cease functioning and, if left for too long, will cause irreparable damage.

A short circuit, or short, is when the power and ground of a circuit are connected without a load (like our resistor) in between, which causes a lot of issues. To learn more, check out the Further reading section of this chapter, or any introduction to an electronics book.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.96.214