0

I am a beginner using a raspberry pi 1 model A+ to create a production counter that would count the material as it would hit the switch and that would be counted as 1. The issue I am having is that I have everything set up but I won't work.

I have NC (red wire connected to Pin 17 a 3V3)
I have NO black wire in pin 1(3V3) and
I have a C connection to a yellow wire connected to a 10k resistor that's connected to the white wire that's connected to the ground.

I have created a small code that would just test the switch through the raspberry pi.

    import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM) GPIO.setup(17,GPIO.IN)

print("Press button")

while GPIO.input(17)==0: pass print("Thanks")

GPIO.cleanup()

Set up

Milliways
  • 62,573
  • 32
  • 113
  • 225
Kevinh2
  • 9
  • 2

1 Answers1

2

It is impossible to tell what you have connected from the picture.
Either draw a circuit (there is Schematic tool above) or describe what is connected to what.
You don't seem to have anything connected to BCM 17.

The program is poor, and not the best way to see what is going on. There are many tools which don't require programming e.g.
raspi-gpio get 17 or Is the gpio readall command compatible with RPi 4?

I suggest https://gpiozero.readthedocs.io/en/v1.6.2/recipes.html#button which is easier to use and includes lots of helpful circuit & programming hints.


EDIT

You don't have any connection to GPIO.
DO NOT connect both NO NC.
DO NOT put a resistor in series, use a pullup.
Connect to GPIO BCM17 pin 11.

See https://elinux.org/RPi_GPIO_Interface_Circuits for examples.

It is inadvisable to connect a switch to 3.3V, an accidental short risks destroying your Pi - use GND as common.

Milliways
  • 62,573
  • 32
  • 113
  • 225