Based on pi4j-v2 Raspberry Pi equipment application SDK. You can use the SDK to create common equipment and control the equipment for base functions easily.
[Note] The current tests only pass on the Raspberry Pi 4B
- Active Buzzer
- Passive Buzzer
- Button
- LED Light
- PCF8591
- HCSR04
- DHT11
- DHT22
The equipment list will be updated continuously.
- Add dependency to pom.xml
<dependency>
<groupId>cn.tpkf.rpi</groupId>
<artifactId>rpi-device-sdk</artifactId>
<version>0.0.1</version>
</dependency>
- A simple example
public static void main(String[] args) {
// Create Pi4J context
Context context = Pi4J.newAutoContext();
// Create a new Device Manager
DeviceManager deviceManager = new DeviceManager(context);
// Create a new device example LED and blink
Led led = new Led(deviceManager, "led-4", "LED", BCMEnums.BCM_4);
led.blink(1, 5, TimeUnit.SECONDS);
//shutdown led
led.shutdown();
//shutdown device manager
deviceManager.shutdown();
}
Thank PI4J very much for providing such a good raspberry pi I/O library.