gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Making a Led Blink

Sun Jan 13, 2019 6:56 pm

I have bought the Vilros Ultimate Starter Kit Raspeberry Pi 3 B+ on Amazon that consists of a breadboard, breakout kit, resistors and some LEDS that I wanted to try this Sunday.
Unfortunately it doesn't work, I am trying pin #21 but nothing happens.

I have tried the following code on Pyton, saved it under LED.py and run it with sudo python LED.py but nothing happens.

P.S: Longer pin is on the same side as the resistor.

Code: Select all

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
print "LED on"
GPIO.output(21,GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(21,GPIO.LOW)
Would someone please advise me if I am doing something wrong or should I consider the breadboard, breakout kit faulty and contact Amazon.

Thank you

Image1: https://imgur.com/a/2BN8rt4
Image2: https://imgur.com/a/PNVx8sc
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

gordon77
Posts: 3912
Joined: Sun Aug 05, 2012 3:12 pm

Re: Making a Led Blink

Sun Jan 13, 2019 7:10 pm

The led in the photo looks like it's plugged into row 21 on the board, where it's connected to nothing? Is the resistor in row 20?

gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Re: Making a Led Blink

Sun Jan 13, 2019 8:44 pm

Sorry for the confusion. I took photos when I was testing pin #20 and I changed the resistor position afterwards. Now everything is at pin #21 and I am using the diode (+) for the resistor but the problem continues: No blinking

Any kind of suggestions would be very helpful.
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

User avatar
rpiMike
Posts: 760
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: Making a Led Blink

Sun Jan 13, 2019 9:23 pm

Post a picture with it correctly wired - sounds like your led may be the wrong way round !

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Making a Led Blink

Mon Jan 14, 2019 10:21 am

Easy way to check your LED is connected the right way round is to look for the flat on the bottom edge of the LED, the pin on the same side of the flat goes to the ground side of your circuit.

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Burngate
Posts: 5870
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Making a Led Blink

Mon Jan 14, 2019 10:51 am

Neither of those two pictures shows a connection to either ground or 3v3
As rpiMike says,
rpiMike wrote:
Sun Jan 13, 2019 9:23 pm
Post a picture with it correctly wired

User avatar
DarkPlatinum
Posts: 808
Joined: Thu Nov 02, 2017 2:30 pm
Location: Unknown
Contact: Website

Re: Making a Led Blink

Mon Jan 14, 2019 11:28 am

Does your LED work? It may have burned out.
1 * Raspberry Pi Zero W, 1 * Raspberry Pi 2, 1 * Raspberry Pi 3 1 * Raspberry Pi 3B + :mrgreen:

Check Out My Raspberry Site (Run on a Raspberry Pi 3B :) ): Https://Html.dynu.net

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Making a Led Blink

Mon Jan 14, 2019 11:45 am

Also looking at your code you LED will only light up once if you want it to blink on and off you need a loop in your code

Code: Select all

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
while True:
    print "LED on"
    GPIO.output(21,GPIO.HIGH)
    time.sleep(1)
    print "LED off"
    GPIO.output(21,GPIO.LOW)
    time.sleep(1)
    
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Re: Making a Led Blink

Mon Jan 14, 2019 7:28 pm

Somehow, the LED is alive now. I can't understand what was wrong yesterday but I can presume it is the fact that I've been using the numbers from the breadboard (pin #20) instead of the number from the cobbler's pin (#21)

Thank you guys for all your help again.

Code: Select all

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(21,GPIO.OUT)
print "LED on"
GPIO.output(21,GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(21,GPIO.LOW)
It's alive: https://imgur.com/a/jHHPW1u
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

gordon77
Posts: 3912
Joined: Sun Aug 05, 2012 3:12 pm

Re: Making a Led Blink

Mon Jan 14, 2019 7:46 pm

You appear to be connecting the led between GPIOs #20 and #21, so l would suggest you had #20 high before and now it's low, and you have no resistor in series with the led, which may damage your Pi.
I would move the joint between led and resistor to row #22 on the breadboard.
Attachments
IMG_20190114_195544.jpg
IMG_20190114_195544.jpg (33.13 KiB) Viewed 949 times

gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Re: Making a Led Blink

Mon Jan 14, 2019 9:31 pm

Correct me if I am wrong on the following, If I've used the LED on pin #20 and the diode (+) of the LED is on the same horizontal row on the breadboard as the resistor would it still affect the RPi?

I am literally using the numbered pins of the GPIO and by the looks of it their marked on the cobbler.

Regarding the rest of the information you shared with me, I honestly couldn't quite grasp it, I need to read again tomorrow after I've rested my brain after +10 hours of work plus playing with the RPi at home.

Example: https://imgur.com/a/PNVx8sc
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

drgeoff
Posts: 9260
Joined: Wed Jan 25, 2012 6:39 pm

Re: Making a Led Blink

Mon Jan 14, 2019 11:49 pm

The leg of the LED in row 21 of the breadboard does not appear to be connected to anything. The resistor appears to be connected to two pins of the cobbler.

PhatFil
Posts: 1197
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Making a Led Blink

Tue Jan 15, 2019 1:55 am

a 3v coin cell is a great led/polarity tester, hold a led leg against each side of a 3v coin cell ( ie cr2032) if it does not light swap it around and if it still fails to light the led is burnt out, when it does light the -ve leg will be on the -ve terminal of the battery and the +ve leg will be connecting to the batterys +ver terminal ;)

gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Re: Making a Led Blink

Tue Jan 15, 2019 8:27 am

drgeoff , indeed, 21 doesn't have a resistor next to it because that specific leg is the cathode(-), the anode (+) is on the same horizontal row as the resistor on pin 20. I've placed the long leg a row up and the small leg a row down.
Does it make sense what I just did? Maybe I am not making a lot of sense.
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Re: Making a Led Blink

Tue Jan 15, 2019 8:29 am

PhatFil, great way of testing it, I will give it a go when I arrive home. Priceless response. I wouldn't have known how to google it for the life of me :)
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

gordon77
Posts: 3912
Joined: Sun Aug 05, 2012 3:12 pm

Re: Making a Led Blink

Tue Jan 15, 2019 8:53 am

This is what I mean
Led between row 20 (gpio21) and row 22. I assume gpio 21 is in row 20.
resistor between row 22 and row 15 (gnd)
Attachments
Image3.jpg
Image3.jpg (90.04 KiB) Viewed 868 times

gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Re: Making a Led Blink

Tue Jan 15, 2019 9:30 am

Oh. That one was my first post and was a mistake for not arranging everything accordingly before taking a photo.

Image: https://imgur.com/a/jHHPW1u - In this image on the breadboard number 20 is used for the LED (diode +) and the resistor.

Out of all the images, is my understanding correct in this one?
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Making a Led Blink

Tue Jan 15, 2019 9:45 am

No, you still have the resistor and the LED connected to gpio 21

Image

you can clearly see gpio21 is on line 20 of your bread board and so are the resistor and LED connections ( blue arrows)


to make it like gordon77's example you need to move the LED and resistor connections to the holes indicated in this image

Image

which is line 21 of the breadboard
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

gordon77
Posts: 3912
Joined: Sun Aug 05, 2012 3:12 pm

Re: Making a Led Blink

Tue Jan 15, 2019 9:47 am

None of you photos are correct. you are joining the led and resistor at another gpio point which is wrong.
Try building what i have shown.

gordon77
Posts: 3912
Joined: Sun Aug 05, 2012 3:12 pm

Re: Making a Led Blink

Tue Jan 15, 2019 9:48 am

pcmanbob wrote:
Tue Jan 15, 2019 9:45 am
No, you still have the resistor and the LED connected to gpio 21



you can clearly see gpio21 is on line 20 of your bread board and so are the resistor and LED connections ( blue arrows)


to make it like gordon77's example you need to move the LED and resistor connections to the holes indicated in this image



which is line 21 of the breadboard
I used row 22 BUT row 21 is OK as well as nothing else is using it.

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Making a Led Blink

Tue Jan 15, 2019 9:53 am

gordon77 wrote:
Tue Jan 15, 2019 9:48 am

I used row 22 BUT row 21 is OK as well as nothing else is using it.
So you did but you also had gpio21 on breadboard row 21 so I just used your example but changed breadboard line numbers to match gabrielbalan's breadboard numbers.

I some times wish I could just reach out and fix it, so much easier to show someone in person.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

gordon77
Posts: 3912
Joined: Sun Aug 05, 2012 3:12 pm

Re: Making a Led Blink

Tue Jan 15, 2019 10:05 am

I am not sure from the photos perspective if gpio #21 is in row 21 or 20, I assumed 20.

pcmanbob
Posts: 5944
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Making a Led Blink

Tue Jan 15, 2019 10:51 am

gabrielbalan I don't know how new you are to using a breadboard, but I suspect this might be your first attempt.

So might I suggest some reading for you on the subject

https://learn.sparkfun.com/tutorials/ho ... breadboard

https://learn.sparkfun.com/tutorials/ho ... rd-circuit
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Burngate
Posts: 5870
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Making a Led Blink

Tue Jan 15, 2019 10:58 am

Down both sides of your breadboard are two columns of holes: on the left they're labelled 3V3, and on the right 5V. On both sides the blue lines are ground.

So why aren't you using the ground on the right? It'd be far easier.

gabrielbalan
Posts: 28
Joined: Fri Jan 04, 2019 11:22 pm
Location: London

Re: Making a Led Blink

Tue Jan 15, 2019 11:05 am

Burngate wrote:
Tue Jan 15, 2019 10:58 am
Down both sides of your breadboard are two columns of holes: on the left they're labelled 3V3, and on the right 5V. On both sides the blue lines are ground.

So why aren't you using the ground on the right? It'd be far easier.
Burngate, I will need further documentation because this is my first try (and I don't want it to be my last one and fry the RPi)
Thank you for your help. I will come back to this thread whenever I get stuck.
Trial and error
Stay in the saddle
Deliver quality
Do more. Do more
Do it again. Do it again. Do it again

Return to “Beginners”