Wiring setup for Rpi:
I have an rpi 3, and I've recently started experimenting with the GPIO side of things. I'm new to electronics in general, although I do computer programming regularly.
I have a 3MM Green LED that I've connected to my breadboard. I have a jumper wire running from Pin#39 (ground) to my negative terminal, and a 47K Ohm resistor connected to my LED. I also have a jumper wire from Pin#7 (GPIO04) to the same LED. If this was poorly explained, there's a picture attached above.
I've mostly followed instructions in this video tutorial as far as enabling I2C/SPI. The same code is essentially used, which I'll post here (though it's minorly tweaked):
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
for i in range(5):
GPIO.output(7,True)
time.sleep(5)
GPIO.output(7,False)
time.sleep(5)
GPIO.cleanup
The code runs without exception from Python, but the LED never switches off. In fact, simply making the connections via the wires makes the LED turn on and stay on. It makes me think that either my wiring connections are wrong, or my understanding of how GPIO works is flawed (which it may; again, I'm new to this). I'd be grateful if anyone has any guidance on how to go about troubleshooting this, or if my understanding of how to do this seemingly simple task is missing something. I can provide more information if needed.
Put simply:
Wiring my LED to the GPIO pins turns the LED on. Why is this? No code I run on the RPI seems to affect the LED or power output from the GPIO. Is this expected? That GPIO will always just be sending power through?
GPIO04
... and try to controlGPIO.output(7
.... are you sure that shouldn't be4
?