Introduction: Simple Inputs on the Raspberry Pi

This is not the only way of making three inputs or more for the Raspberry Pi but it is the simplest.

The inputs are three little tactile switches.

The rest is one 2 kohm resistor.

The good news is that it costs pence, the bad news is that the switches and the resistor usually have to be bought in 100's!

The Raspberry Pi pins (pin 3, 5,7) that are suitable are SDA, SCL, and GPIO4

Pin 3 and 5 (SDA and SCL) already have a 1.6 kohm pull-up resistor on them. That is because they are used for I2C. When used as an input they are defined by the software as a GPIO. Pin 7 is a GPIO but it does not have a pull-up (unless the software has programmed a pull-up) That what the 2 kohm resistor is for It goes between the pin 7 and pin 1 (3v3). Each of the switches are connected between a input pin and 0v. The switches have four (curly?) legs The pair on the each end are the switches; the pair on each side are connected together. The legs will need to be straightened to go in the plugin board, or three tactile switches will fit into an 18pin Dual In Line socket and that can be plugged into the board.

On a plugin breadboard connect to Pins 1,(3v3) 3,(SDA)5, (SCL)7, (GPIO4) and 9 (0v). Connect the 2 kohm resistor from GPIO4 to 3v3, then the switches, one side of each switch to each Raspberry Pi input, the other side joined to each other and then to 0v.

The software will define the pins as GPIOs and as inputs and test each input to see if it is 0v. (Hint. give these inputs values of 1, 2 and 4 (yes binary) and add them) Then the software should do something (e.g. light a LEDs on pins 11,13,15 ? or write a message on the screen). There is no software for this instructable unless you write it. There is excellent advice on writing programs in Python on other instructables and Raspberrypi.org.

More Inputs? Let's have three more for example

A. Three more GPIOs each with a resistor (10 kohm) and a switch. (cost more than doubles!)

B. With working software, pressing "1" and "2" at the same time gives 3. So put two more switches close together with one connected as "1" and one connected as "2" and carefully glue a matchstick across the two little pips. Do it again for "2" and "4", and "1" and "4". .........There has got to be a better way!

C. Let's try out a little electronic (inverting) buffer. Connect a NPN transistor (any little one will do!) with its emitter to 0v, its collector to the "1" switch / Raspberry Pii input, and the base to 10 kohm; then other end of the resistor to one side of this extra switch The other side of this switch goes to 3v3. Pressing the switch just put in should have the same effect as pressing the "1" switch. Note that the buffer inverts, logic "0" becomes "1", logic "1" becomes" 0".

Put another NPN transistor to the "2" switch in the same way, but this time the resistor joins the transistor base to the other resistor /switch join Now press the new switch. "3"? Both Raspberry Pi inputs with one switch. With a little bit of electronic trickery, the three more switches that read as 3, 5, 6 can be added, and still only use three inputs to the Raspberry Pi. (cost soars to 25p!).

D Use a triple three input NOR (CA4025) (or a triple three input AND (CA4073)), six switches with 6 resistors to 3v3.(and the 2 kohm resistor). Use the switches wire ( like in C above), that is, the switch connected to 3v3 and its resistor connected to 0v. . The connection of the switch and resistor goes to the input pin of the NOR gate Pressing a switch puts "1" on the NOR gate's input. With all the inputs unpressed "0"s, the outputs of the NOR are all "1" Press any one switch, the output it is connected to will become "0" .

Connecting the three input three output NOR (CA4025):--

Switch 1 to an input going to output 1 on the NOR gate (connected to input 1 on Raspberry Pi )

Switch 2 to output 2 on the NOR gate (and the input 2 on the Raspberry Pi)

Switch 3 ic connected to another input (to output 1) and another input going to output 2.

Switch 4 to the input going to the third output of the NOR gate (and the third input on the Raspberry Pi )

Switch 5 to output 1 and 4

Switch 6 to 4 and 2

.Connect 0v to Vss (pin 7). Connect 3v3 to Vdd (pin 14).

If the software is displaying the sum of the key presses (as in hint), then it should work straight away

And AND gates? If the switches are connected to the 0v, and the resistors to the 3v3, then the voltage at the resistor /switch join when the switch is pressed will go to 0v = "0" . With all unpressed switches giving "1"s (giving a "1" AND output) when any pin is pressed it will give a "0" . (the CA4025 and the CA4073 have identical pin connections )

That's De Morgan's Theorem:- Invert the inputs , then change the OR to AND ( or AND to OR) and invert the output. (If an inverted logic signal is inverted, it is back to what is was.)

--------------------------------------------------------------------------------------------------------------------------------------------------

Software Quote:- A (Monty) Python line " 7?? don't be silly don't do 7s be =0". Now how did that happen?

Step 1: Figures

Step 2: