vajra11
Posts: 98
Joined: Thu Jul 05, 2018 4:44 am

Blinking led on raspberry pi in c

Sun Jul 08, 2018 2:56 pm

I am trying to blink led on raspberry pi. I have raspberry Pi3 . I am following this link http://wiringpi.com/examples/blink/
I followed all step but My led is not blinking. What could be wrong

This is output of terminal
2018-07-08-144601_1280x1024_scrot.png
2018-07-08-144601_1280x1024_scrot.png (40.24 KiB) Viewed 1996 times

Heater
Posts: 13629
Joined: Tue Jul 17, 2012 3:02 pm

Re: Blinking led on raspberry pi in c

Sun Jul 08, 2018 3:25 pm

What is wrong is that it does not work.

I suspect that nobody can help unless you show the code you are actually using and explain exactly how you have wired up your LED.

Might help to mention exact Raspi model and operating system version as well.

My suspicion is that if you had followed the instructions you have linked to correctly then it would work.

Is your LED the right way around for example?
Memory in C++ is a leaky abstraction .

vajra11
Posts: 98
Joined: Thu Jul 05, 2018 4:44 am

Re: Blinking led on raspberry pi in c

Sun Jul 08, 2018 4:22 pm

Heater wrote:
Sun Jul 08, 2018 3:25 pm
What is wrong is that it does not work.

I suspect that nobody can help unless you show the code you are actually using and explain exactly how you have wired up your LED.

Might help to mention exact Raspi model and operating system version as well.

My suspicion is that if you had followed the instructions you have linked to correctly then it would work.

Is your LED the right way around for example?
Raspberry Pi 3 Model B Rev 1.2

Raspbian GNU/Linux 9 (stretch)

code

Code: Select all

#include <wiringPi.h>
int main (void)
{
  wiringPiSetup () ;
  pinMode (0, OUTPUT) ;
  for (;;)
  {
    digitalWrite (0, HIGH) ; delay (500) ;
    digitalWrite (0,  LOW) ; delay (500) ;
  }
  return 0 ;
}
LED connection
blink1.jpg
blink1.jpg (51.33 KiB) Viewed 1968 times

1dot0
Posts: 430
Joined: Mon Nov 28, 2016 12:31 pm

Re: Blinking led on raspberry pi in c

Sun Jul 08, 2018 4:47 pm

hi,
Does wiringPi work correctly? What happens if you type in the console
gpio -v
gpio readall
?
Did you check if you really had connected to GPIO 0 and not to a different neighbor pin?
Is the LED connected correctly? does the LED turn on if you disconnect the wire to GPIO 0 and then connect to +3.3V?

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

Re: Blinking led on raspberry pi in c

Sun Jul 08, 2018 4:54 pm

Works fine for me - have you tried turning the LED around. Post an actual photo of your wiring.

Image

vajra11
Posts: 98
Joined: Thu Jul 05, 2018 4:44 am

Re: Blinking led on raspberry pi in c

Sun Jul 08, 2018 6:54 pm

rpiMike wrote:
Sun Jul 08, 2018 4:54 pm
Works fine for me - have you tried turning the LED around. Post an actual photo of your wiring.
Take look at wiring
2018-07-08-185032_1280x1024_scrot.png
2018-07-08-185032_1280x1024_scrot.png (39.07 KiB) Viewed 1921 times
IMG_20180709_000142.jpg
IMG_20180709_000142.jpg (100.46 KiB) Viewed 1921 times

Heater
Posts: 13629
Joined: Tue Jul 17, 2012 3:02 pm

Re: Blinking led on raspberry pi in c

Sun Jul 08, 2018 7:44 pm

You have the red wire on pin 6 which is ground.

Which is very confusing.

Are you sure that LED is the right way around?
Memory in C++ is a leaky abstraction .

vajra11
Posts: 98
Joined: Thu Jul 05, 2018 4:44 am

Re: Blinking led on raspberry pi in c

Mon Jul 09, 2018 2:50 am

Heater wrote:
Sun Jul 08, 2018 7:44 pm
You have the red wire on pin 6 which is ground.

Which is very confusing.

Are you sure that LED is the right way around?
Thanks to all of you. I had connected led in wrong direction. now its flashing

Return to “C/C++”