Tag Archives: Raspberry Pi

wiringPi GPIO only pin 7 working

wiringPi GPIO only pin 7 working

 

So as I continue to work with wiringPi GPIO in the C/C++ Language I had a fun experience trying to drive the motors for the robot my daughter and I are building. We are using the L298N driver board
, and I am programming in C/C++ using wiringPi to control the GPIO however I could only get Header 7/Pin 7 to actually kick on the motor. I struggled with this for a while, I could perform all of the functions of the driver through swapping wires to that pin but Header/Pin 11, 13, or 15 with wiringPi. In exasperation I started searching the wiringPi website and came across a graphic that I should have found earlier:

wiringPi GPIO only pin 7 workingThus I found out that there was a large difference between Header number and the pin number and that pin 7 was the only one that had the same number in both. Header 11 is wiringPi pin 0, Header 13 is wiringPI pin 2, and header 15 is wiringPi pin 3. Learn more about the wiringPi Library here

Back to work on this:

Raspberry Pi robot construction GPIO wiringPI

Get a new domain name, or an unlimited hosting service to host multiple websites! Some services are 50% off.
Put your business online!  Get a $8.99 .COM/.NET from GoDaddy!

geany undefined reference to ‘WiringPiSetup’

geany undefined reference to ‘WiringPiSetup’

So you are playing around with raspberry pi and the GPIO functions and you want to use the wiringPi library to help you accomplish this. You’ve been using geany as your IDE and you keep getting the: geany undefined reference to ‘WiringPiSetup’ error message.

undefined reference to wiringpisetup

First make sure you have installed wiringPi correctly.  If installed correctly the key to making this work is to go into the Build -> Set Build Commands Menu and then add:
-lwiringPi to the Build box under commands.

geany undefined reference to wiringpisetup

You may also need to add “sudo” in front of the execute commands or you will get a “wiringPiSetup: Must be root. (Did you forget sudo?)” error.  Then go Compile, Build, and Execute your file or in geany F8, F9, F5.

Need some example code:


#include "stdio.h" //use carrots here... wordpress won't let me for some reason
#include "wiringPi.h" //use carrots here... wordpress won't let me for some reason

main(){

if(wiringPiSetup() == -1)
printf(“ERROR”);
pinMode(7,OUTPUT);

main(){

if(wiringPiSetup() == -1)
printf(“ERROR”);
pinMode(7,OUTPUT);

printf(“Working”);
int i =0;
for(i =0;i<=5;i++){
digitalWrite(7,HIGH);
delay(1000);
digitalWrite(7,LOW);
delay(1000);
}

return 0;
}