- #1
pairofstrings
- 411
- 7
Hello. I have a following C programming language code that blinks an LED ON and OFF.
I fetched the code from here.
The code blinks an LED ON and OFF at pin 12.
My question is, how does the program precisely locate pin 12 on the board and does not go astray and access some other pin mistakenly.
So, I have a question like this: Is the design of Raspberry Pi's architecture, pin locations, components on board are stored some where on the Raspberry Pi device itself? And in this case how does an LED blink correctly at pin 12 as per the program?
I intend to write custom library functions for Raspberry Pi.
I have downloaded bcm2835.c file and saw the code but cannot figure out how the above code makes a precise move to blink an LED at pin 12.
Thank you.
Code:
#include<bcm2835.h>
#define LED RPI_GPIO_P1_12
int main(int argc, char **argv)
{
if(!bcm2835_init()) return 1;
bcm2835_gpio_fsel(LED, BCM2835_GPIO_FSEL_OUTP);
unsigned int delay(1000);
while(1)
{
bcm2835_gpio_set(LED);
bcm2835_delay(delay);
bcm2835_gpio_clr(LED);
bcm2835_delay(delay);
}
}
I fetched the code from here.
The code blinks an LED ON and OFF at pin 12.
My question is, how does the program precisely locate pin 12 on the board and does not go astray and access some other pin mistakenly.
So, I have a question like this: Is the design of Raspberry Pi's architecture, pin locations, components on board are stored some where on the Raspberry Pi device itself? And in this case how does an LED blink correctly at pin 12 as per the program?
I intend to write custom library functions for Raspberry Pi.
I have downloaded bcm2835.c file and saw the code but cannot figure out how the above code makes a precise move to blink an LED at pin 12.
Thank you.
Last edited: