You're viewing YouTube in English (US). You can change this preference below.
You're viewing YouTube in English. You can change this preference below.

LEDs on Raspberry Pi GPIO with Java Pi4J - Start to Finish

14,776 views

Loading...

Loading...

Transcript

The interactive transcript could not be loaded.

Loading...

Loading...

Rating is available when the video has been rented.
This feature is not available right now. Please try again later.
Published on Aug 2, 2015

I have found a lot of really great tutorials on lighting LEDs on the Raspberry Pi through the GPIO pin array using Python. I wanted to share my experiences doing the same but with Java and the Pi4J framework and using the browser to activate the LED.

UPDATE: We work more with the Pi4J Library in the next video: https://www.youtube.com/watch?v=NMR_2...

To follow along with this video, you'll definitely want to check out the Pi4J website. The website includes a key diagram that we'll use for creating a simple circuit on the Raspberry Pi with only one LED. You'll also find documentation on the framework, among other helpful information.

The Pi4J Project:
http://pi4j.com/

Simple LED circuit Wiring Diagram:
http://pi4j.com/example/control.html

Pi4J Documentation:
http://pi4j.com/apidocs/index.html

In order to properly build the project on the Raspberry Pi, you'll want to have Maven installed. There are some automated ways to install Maven on the Raspberry Pi, but I prefer the manual method. It's quick and painless, and it avoids downloading and installing a large volume of supporting packages. Check out my Maven on Raspberry Pi Video:

https://www.youtube.com/watch?v=czT2-...

Spring Boot is also key to this project. It not only enables us to get a Java application up and running quickly, but it quickly helps us wire up some REST controllers and embeds Tomcat into our project so that it can accept web requests. Since we are using the browser to activate our LED, Spring Boot's assistance really gets us what we need quickly.

For help with Spring Boot, check out my Spring Boot tutorial on getting Spring MVC up and running quickly:

https://www.youtube.com/watch?v=n96dN...

You'll notice a slightly embarrassing stumble on my part. Not too great, but it will give some of you newbies a look at how to recover, adjust, rebuild and redeploy your application to correct issues.

I highly encourage you to write the code yourself to get a feel for what it entails, but you're welcome to check out the code that I just submitted specifically for this video. You can check it out this way:

git clone https://github.com/mchandler/pi4led.git

Or just go ahead and browse the public repository:

https://github.com/mchandler/pi4led

I really appreciate you watching this video. Don't forget to LIKE and SUBSCRIBE. It's hugely helpful to me. Thanks so much!

Check out more with Pi4J in our next video: https://www.youtube.com/watch?v=NMR_2...

Join our Facebook Community:
http://www.facebook.com/techzonk

Follow us on Twitter:
http://www.twitter.com/techzonk

Comments • 13

ThatDanoBloke
I don't know if I just heard him right, did he call an LED a 'lead'? facedesk
View all 3 replies
Hide replies
Walter P
hello guys first of all thanks for your great work. Actually I'm programming my raspy 3 model B by using a java cross compiler under netbeans on windows. Raspy has the jre folder already installed and I have created the jre folder in windows. After a few settings under netbeans I'm ready to program (over ssh) my raspy from windows. Today I have installed the pi4j into my raspy. What I have to do in windws-netbeans side ? ...when I try to import com.etc.etc.etc I get an error of course this is because netbeans doesn't know where to take the library. Other think the pi4j has a lot of java files which call jar files...what I have to do ? Thank a lot !
View reply
Hide replies
Kevin Yancy
Really great! Thanks so much. Just what I needed.
Sivasankar Jayapal
Excellent tutorial. Really helpful and made me get started with building my Raspberry pi application.
Juan Camilo Cifuentes
Hey techzonk i have a problem, i get the hello world mesage, but then when i type in /light i get an error that says "This GPIO pin already exists: GPIO 1". Any help?
View all 4 replies
Hide replies
Ammar Bhutta
Here is my situation I want to develop on eclipse and then transfer to Raspberry PI, I downloaded and referenced all the required Pi4j libraries to setup the control example but getting the error message  <-Pi4J-> GPIO Control Example ... started. "Aug 24, 2015 4:03:19 PM com.pi4j.util.NativeLibraryLoader load SEVERE: Unable to load [libpi4j.so] using path: [/lib/libpi4j.so] java.lang.IllegalArgumentException: The path has to be absolute, but found: \lib\libpi4j.so" when compiling- Can some one help here please
View reply
Hide replies
Scott Maxwell
Hmmm array....say it again... :)
Advertisement
When autoplay is enabled, a suggested video will automatically play next.

Up next


to add this to Watch Later

Add to

Loading playlists...