I have this simple code on Raspberry B+.
#include <wiringPi.h>
#include <stdio.h>
int main (int argc, char** argv)
{
int pin;
if (argc <2)
pin = 7;
else
pin = atoi(argv[1]);
printf("Raspberry Pi wiringPi blink test\n");
if (wiringPiSetup() == -1)
return 1;
pinMode(pin, OUTPUT);
for (;;){
printf("LED On\n");
digitalWrite(pin, 1);
delay(250);
printf("LED Off\n");
digitalWrite(pin, 0);
delay(250);
}
return 0;
}
I want to blink a LED connected to a certain pin.
But for some reason the led is blinking only when connected to pin 7. (I have not tried all other pins though, just 8,31,32,33);
when I try the command gpio -g 6 write 1
(which is for pin 31) the LED glows...
What is wrong with the code?
I figured out!
The wiringPi pin numbering is different from R-Pi! Here is a chart for which pin is which.
It was just a coincidence that pin 7 on R-Pi is pin 7 on wiringPi as well.