Last active
June 22, 2016 23:35
-
-
Save matthewphilyaw/99228f9aaa41f9933e93de5f16ebc48c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <wiringPi.h> | |
int main(void) { | |
int errorno = wiringPiSetupGpio(); | |
// No newline, so I missed this a few times | |
// debugging when it was the line above and this line only | |
// it gets instered before the prompt when the program finishes. | |
printf("Plpo"); | |
if( errorno != -1 ) { | |
// doesn't print because errorno is zero, but printf("error: %d", errorno); will | |
// because you included text in it. So this does work | |
printf("%d", errorno); | |
pinMode(4, OUTPUT); // These functions take BCM GPIO pins http://wiringpi.com/pins/ | |
for(;;) { | |
digitalWrite(4, HIGH); // This needs to be 4 as well and same for the one below | |
delay(500); | |
digitalWrite(4, LOW); | |
delay(500); | |
} | |
} else { | |
printf("An error occured while initializing the GPIO"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turns out the issue was the pin numbers which is terribly confusing from what is documented as it refers to wiringPi pins but uses the BCM GPIO pin numbers (http://wiringpi.com/pins/).