riyas
Posts: 3
Joined: Tue Mar 11, 2014 7:09 am

gpio raspberyy pi

Mon Mar 17, 2014 7:41 am

I am beginner to raspberry pi. i want to write an led blinking program for raspberry pi in C. i have the raspberry board with raspbian Os, i can remotely access the pi board by using putty from my Ubuntu Host and i know how to cross compile,and load the binaries into raspberry pi board and run the program from command line...but am confused that how can i run the led blink program after booting process completed in a while loop as we program in a microcontroller...How can i run other application program like this?

hampi
Posts: 223
Joined: Fri May 31, 2013 11:29 am
Contact: Website

Re: gpio raspberyy pi

Mon Mar 17, 2014 8:50 am

Google for 'daemon programming'. Typically atd, crond, httpd, inetd, ntpd, udevd etc are alreay running in your system. You just add you own daemon program to the system.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: gpio raspberyy pi

Mon Mar 17, 2014 9:40 am

Why not compile on the Pi itself? Large programs may take a while, but simple ones like LED flashing will take a few seconds using the provided gcc compiler. Don't forget the Pi isn't a microcontroller, or an embedded system (although you can use it as one), but a full computer (PC hardware can be used as embedded systems too).

Once you have compiled your program, you can easily get it to run at the end of the boot process by adding a line to /etc/rc.local with the program location and an & on the end. The program will run as root, so you don't need "sudo" to allow it to access /dev/mem to get at the GPIOs.

Return to “General discussion”