티스토리 뷰
728x90
Orange PI Zero - pi4j로 PWM 제어
Orange PI Zero는 하나의 PWM만 지원
배선
Java 소스
import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.OrangePiZeroGpioProvider; import com.pi4j.wiringpi.Gpio; import com.pi4j.wiringpi.SoftPwm; public class SG90PWMMain { private static int PIN_NUMBER = 7; public static void main(String[] args) throws Exception { // //GpioFactory.setDefaultProvider(new RaspiGpioProvider(RaspiPinNumberingScheme.BROADCOM_PIN_NUMBERING)); //GpioFactory.setDefaultProvider(new OrangePiPc2GpioProvider()); //GpioFactory.setDefaultProvider(new NanoPiNEOAirGpioProvider()); GpioFactory.setDefaultProvider(new OrangePiZeroGpioProvider()); // initialize wiringPi library, this is needed for PWM Gpio.wiringPiSetup(); // softPwmCreate(int pin, int value, int range) // the range is set like (min=0 ; max=100) SoftPwm.softPwmCreate(PIN_NUMBER, 0, 50); int counter = 0; while (counter < 3) { // fade LED to fully ON for (int i = 0; i <= 100; i++) { // softPwmWrite(int pin, int value) // This updates the PWM value on the given pin. The value is // checked to be in-range and pins // that haven't previously been initialized via softPwmCreate // will be silently ignored. SoftPwm.softPwmWrite(PIN_NUMBER, i); Thread.sleep(25); } // fade LED to fully OFF for (int i = 100; i >= 0; i--) { SoftPwm.softPwmWrite(PIN_NUMBER, i); Thread.sleep(25); } counter++; } } }
실행
$ sudo java -cp .:pi4j-core.jar:pi4j-gpio-extension.jar SG90PWMMain
실행 영상
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Delphi Tip
- Java
- ble
- android
- flex
- sas2009
- Spring MVC
- SAS
- 일본여행
- Xcode
- 동경
- KOBA
- koba2010
- oracle
- 전예희
- NDK
- JavaScript
- Spring
- 송주경
- ffmpeg
- 지스타2007
- 레이싱모델 익스트림 포토 페스티벌
- Delphi
- MySQL
- Mac
- 서울오토살롱
- ubuntu
- BPI-M4
- 튜닝쇼 2008
- Linux
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함