2

So I wanted to try out my Raspberry 3B+ once again, but I have been sitting here for hours without even being able to turn on a LED.

My code:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(4,GPIO.OUT)

GPIO.output(4,True)
time.sleep(5000)
GPIO.output(4,False)

and here is a picture of the guide I was following, and my connection is the same as his:

Raspberry Pi Connection

I wonder if you guys know why it doesn't work? This is in Python because that was what I used to do.

But I also tried Raspberry Pi out with Pi4J in Java - and there the code ran and all but I couldn't get any power from the GPIO pins and that seems to be the case here as well?

I could use all the help I can get! Thanks!

*Edited: I use WinSCP to transfer specific files to my raspberry (I used it for the Java part, shouldn't have an affect) and I usually connect to my Raspberry through my VNC Viewer

I would also like to say that when I tried multiple GPIO pins to debug it I found that in pin 3 ( 2 SDA ) I didnt even have to put it to HIGH for it to light the LED up? I dont know why this happened, what I've read it shouldn't have done that?

I'll go ahead and check it once again tomorrow but this is just an update to the issue! Thank you!

*2nd Update:

I did a "gpio readall" during the run - this is the result - keep in mind that I switched to BCM 4!

When I switched to BCM 4 it had a very low voltage but it light up, without me even activating it? And when I set it to false it doesnt turn off - so something is weird here

GPIO readall

Pictures (no resistor in this one):

pic1

Pic2

enter image description here

failure

  • 2
    Have you tried turning the LED around - it will only work the correct way round. – CoderMike Oct 25 '19 at 19:44
  • 1
    GPIO18 is also used for SPI have you got that turned on in Raspberry Pi Configuration, Interfaces? pinout.xyz/pinout/pin12_gpio18 – CoderMike Oct 25 '19 at 20:00
  • 1
    What happens if you connect your red wire to pin#1 (3.3v)? What's the value of that resistor (can't see the stripes in enough detail)? @CoderMike pin#18 is only used for SPI1 (which needs special set-up). – Dougie Oct 25 '19 at 20:04
  • 1
    @CoderMike Hey! So I haven't tried that but I made sure to connect the GPIO pin to the longer part of the LED (the anode?) and Ground to the other one! I also dont know what SPI is but I tried different GPIO pins and it didnt work :/ – Liam Oct 26 '19 at 0:40
  • 1
    @Dougie So I did that and it turned on, the hardware part seems to be working - which means that the software might be the issue? I'll add some info in the question – Liam Oct 26 '19 at 0:42
0

This is not an answer to your question, but a guideline to help debug this, and future projects.

Your project consists of 2 parts, software and hardware, either or both may have problems.

The rest of us would debug this in 2 steps.

You could check the pin output with a multimeter or with software like gpio readall. You may want to change the time to make this easier.

You could check the operation of the circuit; in this case (as Dougie suggested) connect the red wire to 3.3V.

  • Hey there Milliways! Thanks for the instructions! So I debugged a long time and I tried checking the voltage and I got nothing when I tried that - I can try it again tomorrow! As I commented above I tried using the 3.3V output and the LED light up! So the hardware part shouldn't be the issue.. I personally think I activate the wrong GPIO! – Liam Oct 26 '19 at 0:46
  • @Liam Your code actually works, although why you would want to set a pin for almost 90 minutes remains obscure. – Milliways Oct 26 '19 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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