0

So I got my python code to run that basically just toggles the LED, but now I tried enabling the GPIO via WiringPi library in C but it doesn't work. Considering python code runs, there isn't really anything wrong with the HW connections.

#include <stdio.h>
#include <wiringPi.h>

// LED Pin - wiringPi pin 0 is BCM_GPIO 17.

#define LED     15

int main (void)
{
  printf ("Raspberry Pi - Gertboard Blink\n") ;

  wiringPiSetup () ;

  pinMode (LED, OUTPUT) ;

  for (;;)
  {
    digitalWrite (LED, 1) ;     // On
    delay (500) ;               // mS
    digitalWrite (LED, 0) ;     // Off
    delay (500) ;
  }
  return 0 ;
}
2
  • The first thing I notice is that the comment and LED pin number definition don't match one is 15 and the other is 17. Commented Jun 24, 2020 at 3:38
  • it was copied off somewhere. just wanted t tested out. okay turns out the BCM pins aren't aligned with WiringPi. So pin 15 maps to pin 16 in wiringpi library.
    – MKD
    Commented Jun 24, 2020 at 3:40

0

Your Answer

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

Browse other questions tagged or ask your own question.