Hi
I am usind a Raspberry Pi 2 Mod B with NetBeans 8.1, Oracle JDK ME 8.2. I have established all connections and the sample program GPIOSample is compiling and running on th RPi but none of the pins is working. After that I removed all extra stuff and only use the code for setting the output pin 7. Added some code to set and reset the pins value. That also compiles but I don't see any pin working. From my point of view it should be RPi GPIO socket number 26. what am I douing wrong?
Regards, harald
Code should go into GPIOSample
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
package com.oracle.jmee.samples.gpio;
import java.io.IOException;
import javax.microedition.midlet.MIDlet;
import jdk.dio.DeviceManager;
import jdk.dio.gpio.GPIOPin;
/**
* GPIOSample demonstrates basic GPIO functionality. The sample opens the
* following DIO devices:
*/
public class GPIOSample extends MIDlet {
// GPIO pin which corresponds to a LED
private GPIOPin led = null;
@Override
public void startApp() {
System.out.println("******************************************");
System.out.println("* GPIO Sample started! *");
System.out.println("******************************************");
try {
int ledPinId = 7;
System.out.println("Opening the GPIO pin with id " + ledPinId + " for the LED");
led = DeviceManager.open(ledPinId);
System.out.println("Success opening GPIO pin id " + ledPinId + " for the LED");
} catch (IOException ex) {
System.out.println("Cannot open pin");
destroyApp(true);
}
boolean val = true;
for( int i=0; i<20; i++)
{
try {
Thread.sleep(500); // I know. Should not be done. Only for testing
}
catch( InterruptedException ex)
{
System.out.println(" !!! Interrupted exception");
}
try {
val = !led.getValue();
led.setValue(val);
}
catch ( IOException ex) {
System.out.println(" caught IOException ex");
}
System.out.println(" *** next state change: " + i + " is " + val);
}
destroyApp(true);
}
@Override
public void destroyApp(boolean unconditional) {
System.out.println("******************************************");
System.out.println("* GPIO Sample destroyed *");
System.out.println("******************************************");
notifyDestroyed();
}
}