0

I was wondering if anyone here may be able to help me.

I currently have a C# program running on a raspberry pi, that detects the state of a toggle switch connected to pin 13, and ground. I have an LED and resistor connected in series to the toggle switch. What I want to happen is for when the switch is pressed, the LED will come on, and the C# program detects the state of the toggle switch.

Currently, when the switch is toggled, the program correctly detects the input, but the LED connected in series does not turn on. I'm guessing this is due to it not having enough current or something? Any advice would be greatly welcome!

2
  • Why not have your switch on a GPIO input and your LED on a seperate GPIO output and use code to change the LED based on the switch?
    – CoderMike
    Sep 13, 2022 at 11:14
  • 1
    Post a circuit.
    – Milliways
    Sep 13, 2022 at 11:43

1 Answer 1

1

Your question left me unclear on exactly how you're proposing to wire your LED and pushbutton. The following may help; if it doesn't help, please feel free to edit your question to eliminate our having to guess.

Two other points:

  1. The resistor value for R1 may be calculated using Ohm's Law, but you will first need an estimate for the voltage drop across the LED. This will give you a rough guide.

  2. You didn't post your code, but if you need help there, please post a new question.

schematic

simulate this circuit – Schematic created using CircuitLab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.