티스토리 뷰
728x90
Orange PI Zero GPIO 설치
출처 : WiringOP for Orange pi zero - Beginners - OrangePi - Powered by
현재 pi4j는 Orange PI PC2 지원하지 않아 수정한 jar를 배포합니다.
$ sudo apt-get install build-essential $ git clone https://github.com/zhaolei/WiringOP.git -b h3 $ cd WiringOP $ chmod +x ./build $ sudo ./build $ gpio -v gpio version: 2.20 Copyright (c) 2012-2014 Gordon Henderson This is free software with ABSOLUTELY NO WARRANTY. For details type: gpio -warranty Banana Pro Details: Type: Banana Pro, Revision: 1.2, Memory: 1024MB, Maker: LeMaker orangepi@OrangePizero:~/WiringOP$ gpio readall +-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+ | | | 3.3v | | | 1 || 2 | | | 5v | | | | 12 | 8 | SDA.0 | ALT5 | 0 | 3 || 4 | | | 5V | | | | 11 | 9 | SCL.0 | ALT5 | 0 | 5 || 6 | | | 0v | | | | 6 | 7 | GPIO.7 | ALT3 | 0 | 7 || 8 | 0 | ALT3 | TxD3 | 15 | 13 | | | | 0v | | | 9 || 10 | 0 | ALT3 | RxD3 | 16 | 14 | | 1 | 0 | RxD2 | ALT5 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1 | 1 | 110 | | 0 | 2 | TxD2 | ALT5 | 0 | 13 || 14 | | | 0v | | | | 3 | 3 | CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO.4 | 4 | 68 | | | | 3.3v | | | 17 || 18 | 0 | ALT3 | GPIO.5 | 5 | 71 | | 64 | 12 | MOSI | ALT4 | 0 | 19 || 20 | | | 0v | | | | 65 | 13 | MISO | ALT4 | 0 | 21 || 22 | 0 | ALT3 | RTS2 | 6 | 2 | | 66 | 14 | SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0 | 10 | 67 | | | | 0v | | | 25 || 26 | 0 | ALT3 | GPIO.11 | 11 | 21 | | 19 | 30 | SDA.1 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.1 | 31 | 18 | | 7 | 21 | GPIO.21 | ALT3 | 0 | 29 || 30 | | | 0v | | | | 8 | 22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | RTS1 | 26 | 200 | | 9 | 23 | GPIO.23 | ALT3 | 0 | 33 || 34 | | | 0v | | | | 10 | 24 | GPIO.24 | OUT | 0 | 35 || 36 | 0 | ALT3 | CTS1 | 27 | 201 | | 20 | 25 | GPIO.25 | OUT | 1 | 37 || 38 | 0 | ALT5 | TxD1 | 28 | 198 | | | | 0v | | | 39 || 40 | 0 | ALT5 | RxD1 | 29 | 199 | +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+
C언어 샘플 소스
#include <wiringPi.h> int main() { wiringPiSetup(); pinMode(7, OUTPUT); while(1) { digitalWrite(7,HIGH); delay(500); digitalWrite(7,LOW); delay(500); } return 0; }
컴파일
$ gcc -Wall -o blink blink.c -lwiringPi -lpthread
실행
$ sudo ./blink
java 샘플 소스
/* * #%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 - 2016 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 * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalOutput; import com.pi4j.io.gpio.OrangePiZeroGpioProvider; import com.pi4j.io.gpio.OrangePiZeroPin; import com.pi4j.io.gpio.PinState; /** * 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 { //GpioFactory.setDefaultProvider(new OrangePiPc2GpioProvider()); //GpioFactory.setDefaultProvider(new NanoPiNEOAirGpioProvider()); GpioFactory.setDefaultProvider(new OrangePiZeroGpioProvider()); 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(OrangePiZeroPin.GPIO_07, "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(); System.out.println("Exiting ControlGpioExample"); } }
실행
$ sudo java -cp .:pi4j-core.jar:pi4j-gpio-extension.jar ControlGpioExample
실행결과
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- SAS
- Spring
- 지스타2007
- android
- 레이싱모델 익스트림 포토 페스티벌
- Xcode
- 전예희
- 튜닝쇼 2008
- ffmpeg
- koba2010
- 서울오토살롱
- flex
- NDK
- 일본여행
- Java
- Spring MVC
- 송주경
- BPI-M4
- Linux
- Delphi Tip
- Mac
- ble
- ubuntu
- JavaScript
- MySQL
- 동경
- KOBA
- Delphi
- sas2009
- oracle
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함