Development Environment
This is a description of the development environment used to interact with Minibot. You'll need a computer with wifi and...
- Windows 7 or greater
- Oracle JDK 8 (jdk-8u102-windows)
- Bonjour for Windows from Apple
- Eclipse Mars 2 or Eclipse Neon (J2EE edition is recommented)
- Pi4J
- Read the first paragraph (re: Pi .vs. dev host installation)
- Add PI4J dependencies to the project
- OPTION 1: Add jar files from extracted lib folder to your Eclipse project
- OPTION 2: Add Maven dependencies by editing the pom.xml
- Add pi4j-core
- Add pi4j-gpio-extensions
- Launchpi Plugin for Eclipse
- Select the "LaunchPI" item from the "Uncategorized" entry
- Default hostname for pi 'raspberrypi.local'. Replace raspberry pi if you change the hostname.
- PuTTY (SSH client)
- Use either PuTTY or the Bitvise SSH Client. Default connection information is:
Connection type: SSH hostname: pibot.local (or hostname.local if it was changed) username: pi password: raspberry
- Use either PuTTY or the Bitvise SSH Client. Default connection information is:
- WinSCP
- A SFTP client used to transfer files between Windows and the Pi Zero. It uses the same connection information used for PuTTY.
- Bitvise SSH Client also has a built-in SFTP client.
- Programming with Oracle jdk.dio
- Sample program DioLed?.java:
import java.io.IOException; import java.lang.InterruptedException; import jdk.dio.DeviceManager; import jdk.dio.gpio.GPIOPin; public class DioLed { public static void main(String[] args) throws IOException, InterruptedException { try (GPIOPin led = DeviceManager.open(23);) { // LED on BCM pin 23 for (int i = 0; i < 10; i++) { led.setValue(i % 2 == 0); Thread.sleep(2000); } } } }
- Sample java.policy file:
// grant all permissions for the DIO framework grant { permission jdk.dio.DeviceMgmtPermission "*:*", "open"; permission jdk.dio.gpio.GPIOPinPermission "*:*", "open,setdirection"; permission jdk.dio.gpio.GPIOPortPermission "*:*"; permission jdk.dio.i2cbus.I2CPermission "*:*"; permission jdk.dio.spibus.SPIPermission "*:*"; permission jdk.dio.uart.UARTPermission "*:*"; };
- Sample dio.properties file (note: pin number is BCM pin number: physical pin 16):
23 = deviceType: gpio.GPIOPin, pinNumber:23, name:GPIO_USER_1, mode:-1, direction:3
- Compile:
javac -cp . DioLed.java
- Run (assumes dio.jar is in same directory):
sudo java -Djava.security.policy=./java.policy -classpath .:./dio.jar \ -Djdk.dio.registry=./dio.properties DioLed
- Sample program DioLed?.java:
Last modified 8 years ago
Last modified on Jul 18, 2017, 1:48:41 PM