PiFace LEDs and Switches with Java on Raspberry Pi

Опубликовано: 08 Октябрь 2024
на канале: Zonk
1,824
7

In this video, I'm using Java with the Pi4J library to enable PiFace switch buttons to work with the PiFace LEDs on the Raspberry Pi. Unlike previous videos, this will be a single class Java application with no front end necessary.

I'm using Maven to build my completed JAR files, so you'll definitely want to make sure you have Maven installed on the Raspberry Pi. There is more than one way to do that, but the way I find works best is demonstrated in one of my previous videos, linked below:

Maven on Raspberry Pi:    • Installing Apache Maven on Raspbery P...  

I definitely encourage you to follow along with the example and write the code yourself. For beginners, it's helpful to type out the code because you're more likely to retain it. If you'd prefer to see the code that I used, or examine the POM file to get a better understanding of my project configuration, you can check out the code from Github:

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

Once your code is completed and deployed to the Raspberry Pi, you'll want to build the app so that it can be executed. Make sure Maven is installed and use the following command to build once you've navigated to the project directory:

mvn package

To run the application, you need to make sure you do so as root. To do that, make use of the following command while inside the project directory:

sudo java -jar /path/to/jar

Thanks so much for watching this video. Don't forget to LIKE and SUBSCRIBE! Check back soon for similar videos!

Join our Facebook Community:
  / techzonk  

Follow us on Twitter:
  / techzonk