import com.pi4j.io.gpio.*;
import com.pi4j.io.gpio.trigger.GpioCallbackTrigger;
import java.util.concurrent.Callable;
/**
* Use the pi4j classes to watch a gpio trigger. This uses the pin number scheme as outlined in:
* http://pi4j.com/pins/model-2b-rev1.html
*/
public class MotionSensor {
public static void main(String[] args) throws InterruptedException {
System.out.printf("PIR Module Test (CTRL+C to exit)\n");
// create gpio controller
final GpioController gpio = GpioFactory.getInstance();
// provision gpio pin #29, (header pin 40) as an input pin with its internal pull down resistor enabled
final GpioPinDigitalInput pir = gpio.provisionDigitalInputPin(RaspiPin.GPIO_29);
System.out.printf("Ready\n");
// create a gpio callback trigger on the gpio pin
Callable<Void> callback = () -> {
System.out.println(" --> GPIO TRIGGER CALLBACK RECEIVED ");
return null;
};
// create a gpio callback trigger on the PIR device pin for when it's state goes high
pir.addTrigger(new GpioCallbackTrigger(PinState.HIGH, callback));
// stop all GPIO activity/threads by shutting down the GPIO controller
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
System.out.println("Interrupted, stopping...\n");
gpio.shutdown();
}
});
// keep program running until user aborts (CTRL-C)
for (;;) {
Thread.sleep(100);
}
}
}
$ sudo java -cp .:pi4j-1.0/lib/pi4j-core.jar MotionSensor
PIR Module Test (CTRL+C to exit)
Ready
--> GPIO TRIGGER CALLBACK RECEIVED
--> GPIO TRIGGER CALLBACK RECEIVED
^CInterrupted, stopping...
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
exit 0
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
$ gpio -v gpio readall
gpio version: 2.32
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Pi 2, Revision: 01, Memory: 1024MB, Maker: Sony
* Device tree is enabled.
* This Raspberry Pi supports user-level GPIO access.
-> See the man-page for more details
-> ie. export WIRINGPI_GPIOMEM=1
LDE 제어하기
소스 작성
$ vi led.c
#include
#include
#define LED1 28 // BCM_GPIO 20
#define LED2 29 // BCM_GPIO 21
int main (void)
{
if (wiringPiSetup () == -1)
return 1 ;
pinMode (LED1, OUTPUT) ;
pinMode (LED2, OUTPUT) ;
for (;;)
{
digitalWrite (LED1, 1) ; // On
digitalWrite (LED2, 1) ; // On
delay (1000) ; // ms
digitalWrite (LED1, 0) ; // Off
digitalWrite (LED2, 0) ; // Off
delay (1000) ;
}
return 0 ;
}
$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()
실행 - Line 1 문자열 출력
$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()
>>> lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
>>> lcd.lcd_string("Raspberry PI", 2)
실행 - Line 2 문자열 출력
$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()
>>> lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
>>> lcd.lcd_string("Raspberry PI", 2)
>>> lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
>>> lcd.lcd_string("Hello world", 2)
실행 - 최종
$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()
>>> lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
>>> lcd.lcd_string("Raspberry PI", 2)
>>> lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
>>> lcd.lcd_string("Hello world", 2)
>>> lcd.GPIO.cleanup()
>>> quit()
소스 lcd.py
#!/usr/bin/python
#
# HD44780 LCD Test Script for
# Raspberry Pi
#
# Author : Matt Hawkins
# Site : http://www.raspberrypi-spy.co.uk
#
# Date : 03/08/2012
#
# The wiring for the LCD is as follows:
# 1 : GND
# 2 : 5V
# 3 : Contrast (0-5V)*
# 4 : RS (Register Select)
# 5 : R/W (Read Write) - GROUND THIS PIN
# 6 : Enable or Strobe
# 7 : Data Bit 0 - NOT USED
# 8 : Data Bit 1 - NOT USED
# 9 : Data Bit 2 - NOT USED
# 10: Data Bit 3 - NOT USED
# 11: Data Bit 4
# 12: Data Bit 5
# 13: Data Bit 6
# 14: Data Bit 7
# 15: LCD Backlight +5V**
# 16: LCD Backlight GND
#import
import RPi.GPIO as GPIO
import time
# Define GPIO to LCD mapping
LCD_RS = 7
LCD_E = 8
LCD_D4 = 25
LCD_D5 = 24
LCD_D6 = 23
LCD_D7 = 18
#LED_ON = 15
# Define some device constants
LCD_WIDTH = 16 # Maximum characters per line
LCD_CHR = True
LCD_CMD = False
LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line
# Timing constants
E_PULSE = 0.00005
E_DELAY = 0.00005
def main():
# Main program block
# Initialise display
lcd_init()
# Toggle backlight on-off-on
#GPIO.output(LED_ON, True)
#time.sleep(1)
#GPIO.output(LED_ON, False)
#time.sleep(1)
#GPIO.output(LED_ON, True)
#time.sleep(1)
# Send some centred test
lcd_byte(LCD_LINE_1, LCD_CMD)
lcd_string("Rasbperry Pi",2)
lcd_byte(LCD_LINE_2, LCD_CMD)
lcd_string("Model B",2)
time.sleep(3) # 3 second delay
# Send some left justified text
lcd_byte(LCD_LINE_1, LCD_CMD)
lcd_string("1234567890123456",1)
lcd_byte(LCD_LINE_2, LCD_CMD)
lcd_string("abcdefghijklmnop",1)
time.sleep(3) # 3 second delay
# Send some right justified text
lcd_byte(LCD_LINE_1, LCD_CMD)
lcd_string("Raspberrypi-spy",3)
lcd_byte(LCD_LINE_2, LCD_CMD)
lcd_string(".co.uk",3)
time.sleep(30)
# Turn off backlight
#GPIO.output(LED_ON, False)
def lcd_init():
GPIO.setmode(GPIO.BCM) # Use BCM GPIO numbers
GPIO.setup(LCD_E, GPIO.OUT) # E
GPIO.setup(LCD_RS, GPIO.OUT) # RS
GPIO.setup(LCD_D4, GPIO.OUT) # DB4
GPIO.setup(LCD_D5, GPIO.OUT) # DB5
GPIO.setup(LCD_D6, GPIO.OUT) # DB6
GPIO.setup(LCD_D7, GPIO.OUT) # DB7
#GPIO.setup(LED_ON, GPIO.OUT) # Backlight enable
# Initialise display
lcd_byte(0x33,LCD_CMD)
lcd_byte(0x32,LCD_CMD)
lcd_byte(0x28,LCD_CMD)
lcd_byte(0x0C,LCD_CMD)
lcd_byte(0x06,LCD_CMD)
lcd_byte(0x01,LCD_CMD)
def lcd_string(message,style):
# Send string to display
# style=1 Left justified
# style=2 Centred
# style=3 Right justified
if style==1:
message = message.ljust(LCD_WIDTH," ")
elif style==2:
message = message.center(LCD_WIDTH," ")
elif style==3:
message = message.rjust(LCD_WIDTH," ")
for i in range(LCD_WIDTH):
lcd_byte(ord(message[i]),LCD_CHR)
def lcd_byte(bits, mode):
# Send byte to data pins
# bits = data
# mode = True for character
# False for command
GPIO.output(LCD_RS, mode) # RS
# High bits
GPIO.output(LCD_D4, False)
GPIO.output(LCD_D5, False)
GPIO.output(LCD_D6, False)
GPIO.output(LCD_D7, False)
if bits&0x10==0x10:
GPIO.output(LCD_D4, True)
if bits&0x20==0x20:
GPIO.output(LCD_D5, True)
if bits&0x40==0x40:
GPIO.output(LCD_D6, True)
if bits&0x80==0x80:
GPIO.output(LCD_D7, True)
# Toggle 'Enable' pin
time.sleep(E_DELAY)
GPIO.output(LCD_E, True)
time.sleep(E_PULSE)
GPIO.output(LCD_E, False)
time.sleep(E_DELAY)
# Low bits
GPIO.output(LCD_D4, False)
GPIO.output(LCD_D5, False)
GPIO.output(LCD_D6, False)
GPIO.output(LCD_D7, False)
if bits&0x01==0x01:
GPIO.output(LCD_D4, True)
if bits&0x02==0x02:
GPIO.output(LCD_D5, True)
if bits&0x04==0x04:
GPIO.output(LCD_D6, True)
if bits&0x08==0x08:
GPIO.output(LCD_D7, True)
# Toggle 'Enable' pin
time.sleep(E_DELAY)
GPIO.output(LCD_E, True)
time.sleep(E_PULSE)
GPIO.output(LCD_E, False)
time.sleep(E_DELAY)
if __name__ == '__main__':
main()
pi4j - 핀 배열
pi4j - 예제
import java.text.SimpleDateFormat;
import java.util.Date;
import com.pi4j.component.lcd.LCDTextAlignment;
import com.pi4j.component.lcd.impl.GpioLcdDisplay;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiGpioProvider;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.io.gpio.RaspiPinNumberingScheme;
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
import com.pi4j.io.gpio.event.GpioPinListenerDigital;
public class LcdExample2 {
public final static int LCD_ROWS = 2;
public final static int LCD_ROW_1 = 0;
public final static int LCD_ROW_2 = 1;
public final static int LCD_COLUMNS = 16;
public final static int LCD_BITS = 4;
public static void main(String args[]) throws InterruptedException {
System.out.println("<--Pi4J--> GPIO 4 bit LCD example program");
// create gpio controller
final GpioController gpio = GpioFactory.getInstance();
// initialize LCD
//new GpioLcdDisplay(LCD_ROWS, LCD_COLUMNS, RaspiPin.GPIO_06, RaspiPin.GPIO_05, RaspiPin.GPIO_04, RaspiPin.GPIO_00, RaspiPin.GPIO_01, RaspiPin.GPIO_03);
final GpioLcdDisplay lcd = new GpioLcdDisplay(LCD_ROWS, // number of row
// supported by LCD
LCD_COLUMNS, // number of columns supported by LCD
RaspiPin.GPIO_11, // LCD RS pin 7
RaspiPin.GPIO_10, // LCD strobe pin 8
RaspiPin.GPIO_06, // LCD data bit 1 25
RaspiPin.GPIO_05, // LCD data bit 2 24
RaspiPin.GPIO_04, // LCD data bit 3 23
RaspiPin.GPIO_01); // LCD data bit 4 18
// provision gpio pins as input pins with its internal pull up resistor
// enabled
/*
final GpioPinDigitalInput myButtons[] = {
gpio.provisionDigitalInputPin(RaspiPin.GPIO_13, "B1", PinPullResistance.PULL_UP),
gpio.provisionDigitalInputPin(RaspiPin.GPIO_07, "B2", PinPullResistance.PULL_UP),
gpio.provisionDigitalInputPin(RaspiPin.GPIO_04, "B3", PinPullResistance.PULL_UP),
gpio.provisionDigitalInputPin(RaspiPin.GPIO_12, "B4", PinPullResistance.PULL_UP)
};
// create and register gpio pin listener
gpio.addListener(new GpioPinListenerDigital() {
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
if (event.getState() == PinState.LOW) {
lcd.writeln(LCD_ROW_2, event.getPin().getName() + " PRESSED", LCDTextAlignment.ALIGN_CENTER);
} else {
lcd.writeln(LCD_ROW_2, event.getPin().getName() + " RELEASED", LCDTextAlignment.ALIGN_CENTER);
}
}
}, myButtons);
*/
// clear LCD
lcd.clear();
Thread.sleep(1000);
// write line 1 to LCD
lcd.write(LCD_ROW_1, "The Pi4J Project");
// write line 2 to LCD
lcd.write(LCD_ROW_2, "----------------");
// line data replacement
for (int index = 0; index < 5; index++) {
lcd.write(LCD_ROW_2, "----------------");
Thread.sleep(500);
lcd.write(LCD_ROW_2, "****************");
Thread.sleep(500);
}
lcd.write(LCD_ROW_2, "----------------");
// single character data replacement
for (int index = 0; index < lcd.getColumnCount(); index++) {
lcd.write(LCD_ROW_2, index, ">");
if (index > 0)
lcd.write(LCD_ROW_2, index - 1, "-");
Thread.sleep(300);
}
for (int index = lcd.getColumnCount() - 1; index >= 0; index--) {
lcd.write(LCD_ROW_2, index, "<");
if (index < lcd.getColumnCount() - 1)
lcd.write(LCD_ROW_2, index + 1, "-");
Thread.sleep(300);
}
// left alignment, full line data
lcd.write(LCD_ROW_2, "----------------");
Thread.sleep(500);
lcd.writeln(LCD_ROW_2, "<< LEFT");
Thread.sleep(1000);
// right alignment, full line data
lcd.write(LCD_ROW_2, "----------------");
Thread.sleep(500);
lcd.writeln(LCD_ROW_2, "RIGHT >>", LCDTextAlignment.ALIGN_RIGHT);
Thread.sleep(1000);
// center alignment, full line data
lcd.write(LCD_ROW_2, "----------------");
Thread.sleep(500);
lcd.writeln(LCD_ROW_2, "<< CENTER >>", LCDTextAlignment.ALIGN_CENTER);
Thread.sleep(1000);
// mixed alignments, partial line data
lcd.write(LCD_ROW_2, "----------------");
Thread.sleep(500);
lcd.write(LCD_ROW_2, "<L>", LCDTextAlignment.ALIGN_LEFT);
lcd.write(LCD_ROW_2, "<R>", LCDTextAlignment.ALIGN_RIGHT);
lcd.write(LCD_ROW_2, "CC", LCDTextAlignment.ALIGN_CENTER);
Thread.sleep(3000);
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
// update time
while (true) {
// write time to line 2 on LCD
//if (gpio.isHigh(myButtons)) {
lcd.writeln(LCD_ROW_2, formatter.format(new Date()), LCDTextAlignment.ALIGN_CENTER);
//}
Thread.sleep(1000);
}
// stop all GPIO activity/threads by shutting down the GPIO controller
// (this method will forcefully shutdown all GPIO monitoring threads and
// scheduled tasks)
// gpio.shutdown(); <--- implement this method call if you wish to terminate
// the Pi4J GPIO controller
}
}
$ sudo java -cp .:../lib/pi4j-core.jar ControlGpioExample
<--Pi4J--> GPIO Control Example ... started.
--> GPIO state should be: ON
--> GPIO state should be: OFF
--> GPIO state should be: ON
--> GPIO state should be: OFF
--> GPIO state should be: ON for only 1 second
ControlGpioExample.java 소스
// START SNIPPET: control-gpio-snippet
/*
* #%L
* **********************************************************************
* ORGANIZATION : Pi4J
* PROJECT : Pi4J :: Java Examples
* FILENAME : ControlGpioExample.java
*
* This file is part of the Pi4J project. More information about
* this project can be found here: http://www.pi4j.com/
* **********************************************************************
* %%
* Copyright (C) 2012 - 2015 Pi4J
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
/**
* This example code demonstrates how to perform simple state
* control of a GPIO pin on the Raspberry Pi.
*
* @author Robert Savage
*/
public class ControlGpioExample {
public static void main(String[] args) throws InterruptedException {
System.out.println("<--Pi4J--> GPIO Control Example ... started.");
// create gpio controller
final GpioController gpio = GpioFactory.getInstance();
// provision gpio pin #01 as an output pin and turn on
final GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_00, "MyLED", PinState.HIGH);
// set shutdown state for this pin
pin.setShutdownOptions(true, PinState.LOW);
System.out.println("--> GPIO state should be: ON");
Thread.sleep(5000);
// turn off gpio pin #01
pin.low();
System.out.println("--> GPIO state should be: OFF");
Thread.sleep(5000);
// toggle the current state of gpio pin #01 (should turn on)
pin.toggle();
System.out.println("--> GPIO state should be: ON");
Thread.sleep(5000);
// toggle the current state of gpio pin #01 (should turn off)
pin.toggle();
System.out.println("--> GPIO state should be: OFF");
Thread.sleep(5000);
// turn on gpio pin #01 for 1 second and then off
System.out.println("--> GPIO state should be: ON for only 1 second");
pin.pulse(1000, true); // set second argument to 'true' use a blocking call
// stop all GPIO activity/threads by shutting down the GPIO controller
// (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
gpio.shutdown();
}
}
//END SNIPPET: control-gpio-snippet
$ git clone https://code.google.com/p/raspberry-pi4j-samples/
$ cd raspberry-pi4j-samples/Relay/src
$ javac -cp ~/pi4j-1.0/lib/pi4j-core.jar relay/Relay02.java
$ sudo java -cp .:../../../pi4j-1.0/lib/pi4j-core.jar relay.Relay02 0
GPIO Control - pin 0... started.
--> GPIO state is Low
Type Q to quit.
So? > 1
Setting pin to high
--> GPIO state is High
So? > 0
Setting pin to low
--> GPIO state is Low
So? > q
Relay02.java 소스
package relay;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.Pin;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
* 5v are required to drive the relay
* The GPIO pins deliver 3.3v
* To drive a relay, a relay board is required.
* (it may contain what's needed to drive the relay with 3.3v)
*/
public class Relay02
{
private static Pin relayPin = RaspiPin.GPIO_00;
public static void main(String[] args) throws InterruptedException
{
int pin = 0;
if (args.length > 0)
{
try
{
pin = Integer.parseInt(args[0]);
}
catch (NumberFormatException nfe)
{
nfe.printStackTrace();
}
switch (pin)
{
case 0:
relayPin = RaspiPin.GPIO_00;
break;
case 1:
relayPin = RaspiPin.GPIO_01;
break;
case 2:
relayPin = RaspiPin.GPIO_02;
break;
case 3:
relayPin = RaspiPin.GPIO_03;
break;
case 4:
relayPin = RaspiPin.GPIO_04;
break;
case 5:
relayPin = RaspiPin.GPIO_05;
break;
case 6:
relayPin = RaspiPin.GPIO_06;
break;
case 7:
relayPin = RaspiPin.GPIO_07;
break;
case 8:
relayPin = RaspiPin.GPIO_08;
break;
case 9:
relayPin = RaspiPin.GPIO_09;
break;
case 10:
relayPin = RaspiPin.GPIO_10;
break;
case 11:
relayPin = RaspiPin.GPIO_11;
break;
case 12:
relayPin = RaspiPin.GPIO_12;
break;
case 13:
relayPin = RaspiPin.GPIO_13;
break;
case 14:
relayPin = RaspiPin.GPIO_14;
break;
case 15:
relayPin = RaspiPin.GPIO_15;
break;
case 16:
relayPin = RaspiPin.GPIO_16;
break;
case 17:
relayPin = RaspiPin.GPIO_17;
break;
case 18:
relayPin = RaspiPin.GPIO_18;
break;
case 19:
relayPin = RaspiPin.GPIO_19;
break;
case 20:
relayPin = RaspiPin.GPIO_20;
break;
default: // Model a+ and B+ go up to 30
System.out.println("Unknown GPIO pin [" + pin + "], must be between 0 & 20.");
System.out.println("Defaulting GPIO_00");
break;
}
}
System.out.println("GPIO Control - pin " + pin + "... started.");
// create gpio controller
final GpioController gpio = GpioFactory.getInstance();
// For a relay it seems that HIGH means NC (Normally Closed)...
final GpioPinDigitalOutput outputPin = gpio.provisionDigitalOutputPin(relayPin); //, PinState.HIGH);
System.out.println("--> GPIO state is " + (outputPin.isHigh()?"High":"Low"));
boolean go = true;
System.out.println("Type Q to quit.");
while (go)
{
String user = userInput("So? > ");
if ("Q".equalsIgnoreCase(user))
go = false;
else
{
int val = 0;
try
{
val = Integer.parseInt(user);
if (val != 0 && val != 1)
System.out.println("Only 1 or 0, please");
else
{
System.out.println("Setting pin to " + (val == 1 ? "high" : "low"));
if (val == 0)
outputPin.low();
else
outputPin.high();
System.out.println("--> GPIO state is " + (outputPin.isHigh()?"High":"Low"));
}
}
catch (NumberFormatException nfe)
{
nfe.printStackTrace();
}
}
}
gpio.shutdown();
}
private static final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
public static String userInput(String prompt)
{
String retString = "";
System.err.print(prompt);
try
{
retString = stdin.readLine();
}
catch(Exception e)
{
System.out.println(e);
String s;
try
{
s = userInput("<Oooch/>");
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
return retString;
}
}