1.Blink LED
http://www.engineersgarage.com/embedded/raspberry-pi/how-to-blink-led-using-raspberry-pi
In this project the Raspberrypi board is loaded with Ubuntu
and is remotely accessed using VNC.
▲Library를 사용하기위해서는 위 파일의 압축을 풀고
/home/pi folder. 경로로 이동시킨다.
To use bcm2835.h on IDE, release .gz Zip file at /home/pi
그다음 아래 경로에 맞춰서 한줄씩 Terminal에 입력하면 된다.
cd bcm2835-1.26
Now use the following commands one by one to finish the installation process.
./configure
make
sudo make check
sudo make install
이제 IDE환경에서 header file을 사용할 수 있다.
Once the installation is completed the library can be included as a header file in any C codes as
#include <bcm2835.h>
//---------------------led blinking code---------------------------
#include<bcm2835.h>
#define PIN RPI_GPIO_PI_11
int main()
{
if (!bcm2835_init()) // initialize the library
return 1;
bcm2835_gpio_fsel (PIN, BCM2835_GPIO_FSEL_OUTP); // Set the pin to be an output
while (1)
{
bcm2835_gpio_write(PIN, HIGH); // Turn it on
bcm2835_delay(500); // wait a bit
bcm2835_gpio_write(PIN, LOW); // turn it off
bcm2835_delay(500); // wait a bit
}
bcm2835_close(); // close the library
return 0;
}
//------------------------------------------ led blinking code --------------------------------------------------//