Analog Pins on the Raspberry Pi
Looking for the Analog Pins on the Raspberry Pi? Unfortunately there are no analog pins on the Raspberry Pi. However you can very easily add 8 analog pins to your Raspberry Pi via the SPI(Serial Peripheral Interface) connection on your GPIO pins and easily read analog input.
You will need an Analog to Digital Converter aka ADC to accomplish this task. It’s a relatively inexpensive piece of equipment but usually after shipping you are going to pay between 4 and 10 dollars. The MCP3008 has 8 analog pins and the MCP3004 has 4 pins.
I recommend putting it on a breadboart the first time you play with the chip.
The indented circle demonstrates the first pin of the analog inputs. Thus the 8 Pins on the side the yellow arrow is pointing to are the channels 0-7 for the analog to digital conversion for your raspberry pi.
The red arrow points to the side the has from left to right. Voltage in, voltage in, ground, SCLK, MISO, MOSI, CE0, and ground. The chip runs on 2.7V – 5.5V and cycles faster at higher voltage.
I will go over how to hook this up, test it, and code it in another post.
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:
Thus 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:
Get a new domain name, or an unlimited hosting service to host multiple websites! Some services are 50% off.
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.
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.
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
if(wiringPiSetup() == -1)
if(wiringPiSetup() == -1)
int i =0;