728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


출처

배선

소스 (L298NMain.java)

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.RaspiPin;

public class L298NMain {

        private static GpioController gpio = null;

        static GpioPinDigitalOutput pin1;
        static GpioPinDigitalOutput pin2;

        public static void forword() {
                System.out.println("GPIO Forward");
                pin1.high();
                pin2.low();
        }

        public static void backword() {
                System.out.println("GPIO Backward");
                pin1.low();
                pin2.high();
        }

        public static void stopFB() {
                System.out.println("GPIO Stop Back Wheel");
                pin1.low();
                pin2.low();
                /*
                try {
                        Thread.sleep(700);
                } catch (Exception e) {
                        e.printStackTrace();
                }
                */
        }

        public static void main(String[] args) throws Exception {
                gpio = GpioFactory.getInstance();
                //gpio.setMode(PinMode.DIGITAL_OUTPUT);
                pin1 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_08);
                pin2 = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_09);

                forword();
                Thread.sleep(2000);
                backword();
                Thread.sleep(2000);

                stopFB();

                gpio.shutdown();
        }
}

컴파일

$ javac -cp .:lib/pi4j-core.jar L298NMain.java

실행

$ java -cp .:lib/pi4j-core.jar L298NMain

실행 영상



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


출처

SG-90 연결선

  • 노란색 = 제어신호
  • 빨간색 = VCC
  • 갈색(또는 검정색) = GND

SG-90제어 C언어 예제 (servo.c)

#include<stdio.h>
#include<wiringPi.h>
#include<softPwm.h>

#define SERVO 26

int main() {
        char str;

        if(wiringPiSetup()==-1)
                return 1;

        softPwmCreate(SERVO,0,200);

        while(1) {
                fputs("select c ,r , l , q : " , stdout);
                scanf("%c" , &str);
                getchar();
                if(str=='c') softPwmWrite(SERVO,15);     //0 degree
                else if(str=='r') softPwmWrite(SERVO,24); //90 degree
                else if(str=='l') softPwmWrite(SERVO,5); //-90 degree
                else if(str=='q') return 0;
        }

        return 0;
}

C언어 예제 컴파일

$ gcc servo.c -o servo -lwiringPi

C언어 예제 실행

$ ./servo

SG-90 제어 Java 예제 소스

import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.RaspiGpioProvider;
import com.pi4j.io.gpio.RaspiPinNumberingScheme;
import com.pi4j.wiringpi.Gpio;
import com.pi4j.wiringpi.SoftPwm;

public class Servo {

        private static int PIN_NUMBER = 12;

        public static void main(String[] args) throws Exception {
                //
                GpioFactory.setDefaultProvider(new RaspiGpioProvider(RaspiPinNumberingScheme.BROADCOM_PIN_NUMBERING));

                // 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, 100);
                int counter = 0;
                while (counter < 3) {
                        // 
                        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);
                        }
                        // 
                        for (int i = 100; i >= 0; i--) {
                                SoftPwm.softPwmWrite(PIN_NUMBER, i);
                                Thread.sleep(25);
                        }
                        counter++;
                }
        }

}

Java 예제 컴파일

$ javac -cp .:lib/pi4j-core.jar Servo.java

Java 예제 실행

$ java -cp .:lib/pi4j-core.jar Servo

실행 영상



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


pi4j

pi4j는 java를 이용해서 gpio 제어하는 java 라이브러리 입니다.
pi4j 라이브러리를 다운 받고 간단하게 LED를 켜고, 끄는 예제를 실행해보겠습니다.

출처

GPIO

pi4j 다운로드, 압축해제, 디렉토리 이동

$ wget http://get.pi4j.com/download/pi4j-1.2-SNAPSHOT.zip
$ unzip pi4j-1.2-SNAPSHOT.zip
$ cd pi4j-1.2-SNAPSHOT

LED 켜고, 끄기 소스

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.RaspiPin;

public class LEDTest {
	
	private static GpioController gpio = null;
	
	static GpioPinDigitalOutput led_pin;
	
	public static void main(String[] args) throws Exception {
		gpio = GpioFactory.getInstance();
		led_pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_08);
		
		// LED 켜기
		led_pin.high();
		Thread.sleep(2000); // 2초 대기
		
		// LED 끄기
		led_pin.low();
		
		// 
		gpio.shutdown();
	}
}

컴파일

$ javac -cp .:lib/pi4j-core.jar LEDTest.java

실행

$ java -cp .:lib/pi4j-core.jar LEDTest



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


출처

V4L2(Video4Linux2) 부팅시 활성화 시키기

$ sudo vi /etc/modules

아래 내용 추가

bcm2835-v4l2

motion 설치

$ sudo apt-get install motion
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다       
상태 정보를 읽는 중입니다... 완료
The following additional packages will be installed:
  ffmpeg libavdevice57 libpq5 libsdl2-2.0-0
제안하는 패키지:
  ffmpeg-doc default-mysql-client postgresql-client
다음 새 패키지를 설치할 것입니다:
  ffmpeg libavdevice57 libpq5 libsdl2-2.0-0 motion
0개 업그레이드, 5개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
2,324 k바이트 아카이브를 받아야 합니다.
이 작업 후 4,718 k바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] 
받기:1 http://archive.raspberrypi.org/debian stretch/main armhf libavdevice57 armhf 7:3.2.10-1~deb9u1+rpt1 [109 kB]
받기:2 http://ftp.harukasan.org/raspbian/raspbian stretch/main armhf libsdl2-2.0-0 armhf 2.0.5+dfsg1-2 [314 kB]
받기:3 http://ftp.harukasan.org/raspbian/raspbian stretch/main armhf libpq5 armhf 9.6.7-0+deb9u1 [117 kB]                                     
받기:4 http://archive.raspberrypi.org/debian stretch/main armhf ffmpeg armhf 7:3.2.10-1~deb9u1+rpt1 [1,516 kB]                               
받기:5 http://ftp.harukasan.org/raspbian/raspbian stretch/main armhf motion armhf 4.0-1 [269 kB]                
내려받기 2,324 k바이트, 소요시간 6초 (371 k바이트/초)                                                                                          
패키지를 미리 설정하는 중입니다...
Selecting previously unselected package libsdl2-2.0-0:armhf.
(데이터베이스 읽는중 ...현재 115814개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../libsdl2-2.0-0_2.0.5+dfsg1-2_armhf.deb ...
Unpacking libsdl2-2.0-0:armhf (2.0.5+dfsg1-2) ...
Selecting previously unselected package libavdevice57:armhf.
Preparing to unpack .../libavdevice57_7%3a3.2.10-1~deb9u1+rpt1_armhf.deb ...
Unpacking libavdevice57:armhf (7:3.2.10-1~deb9u1+rpt1) ...
Selecting previously unselected package ffmpeg.
Preparing to unpack .../ffmpeg_7%3a3.2.10-1~deb9u1+rpt1_armhf.deb ...
Unpacking ffmpeg (7:3.2.10-1~deb9u1+rpt1) ...
Selecting previously unselected package libpq5:armhf.
Preparing to unpack .../libpq5_9.6.7-0+deb9u1_armhf.deb ...
Unpacking libpq5:armhf (9.6.7-0+deb9u1) ...
Selecting previously unselected package motion.
Preparing to unpack .../motion_4.0-1_armhf.deb ...
Unpacking motion (4.0-1) ...
libpq5:armhf (9.6.7-0+deb9u1) 설정하는 중입니다 ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
libsdl2-2.0-0:armhf (2.0.5+dfsg1-2) 설정하는 중입니다 ...
Processing triggers for systemd (232-25+deb9u2) ...
Processing triggers for man-db (2.7.6.1-2) ...
libavdevice57:armhf (7:3.2.10-1~deb9u1+rpt1) 설정하는 중입니다 ...
motion (4.0-1) 설정하는 중입니다 ...
Adding group `motion' (GID 115) ...
완료.
Warning: The home dir /var/lib/motion you specified already exists.
Adding system user `motion' (UID 111) ...
Adding new user `motion' (UID 111) with group `motion' ...
The home directory `/var/lib/motion' already exists.  Not copying from `/etc/skel'.
adduser: Warning: The home directory `/var/lib/motion' does not belong to the user you are currently creating.
Adding user `motion' to group `video' ...
사용자 motion을(를) video 그룹에 등록 중
완료.
ffmpeg (7:3.2.10-1~deb9u1+rpt1) 설정하는 중입니다 ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for systemd (232-25+deb9u2) ...

환경파일(motion.conf) 수정

$ sudo vi /etc/motion/motion.conf

환경파일 수정 내용

 11 daemon on
100 width 320
103 height 240
107 framerate 2
504 stream_localhost off
537 webcontrol_localhost off

실행

$ sudo motion -n
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[0:motion] [NTC] [ALL] motion_startup: Motion 4.0 Started
[0:motion] [NTC] [ALL] motion_startup: Logging to file (/var/log/motion/motion.log)

확인

서비스에 등록

/etc/default/motion 수정 내용

$ sudo vi /etc/default/motion

start_motion_daemon 값 no 에서 yes 로 수정

start_motion_daemon=yes

motion 서비스 등록

$ sudo systemctl enable motion
motion.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable motion

재부팅

$ sudo shutdown -r now

서비스 실행 확인

$ sudo sudo service motion status
● motion.service - LSB: Start Motion detection
   Loaded: loaded (/etc/init.d/motion; generated; vendor preset: enabled)
   Active: active (exited) since Sun 2018-07-08 23:19:36 KST; 1min 8s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 325 ExecStart=/etc/init.d/motion start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/motion.service
 
 7월 08 23:19:35 raspberrypi systemd[1]: Starting LSB: Start Motion detection...
 7월 08 23:19:36 raspberrypi motion[325]: Starting motion detection daemon: motion.
 7월 08 23:19:36 raspberrypi systemd[1]: Started LSB: Start Motion detection.

서비스 비활성화

$ sudo systemctl disable motion
motion.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable motion




개인 설정후 설정 파일로 실행 하기


환경파일(motion.conf) 수정 (motion 경로 생성, 환경파일 복사, vi)

$ mkdir ~/.motion
$ cp /etc/motion/motion.conf ~/.motion/motion.conf
$ vi ~/.motion/motion.conf

환경파일 수정 내용

 25 logfile /home/pi/Documents/motion/motion.log
100 width 640
103 height 480
145 mmalcam_name vc.ril.camera
253 event_gap 10
279 quality 80
273 output_pictures center
293 ffmpeg_output_movies off
392 locate_motion_mode preview
400 locate_motion_style redbox
415 text_changes on
450 target_dir /home/pi/Documents/motion
504 stream_localhost off
537 webcontrol_localhost off

motion 실행

$ motion -c ~/.motion/motion.conf
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /home/pi/.motion/motion.conf
[0:motion] [ALR] [ALL] conf_cmdparse: Unknown config option "mmalcam_name"
[0:motion] [NTC] [ALL] motion_startup: Motion 4.0 Started
[0:motion] [NTC] [ALL] motion_startup: Logging to file (/home/pi/Documents/motion/motion.log)



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


Pi-Camera

출처 : 라즈베리파이에 카메라 입출력을 받아보자. V4L2(Video4Linux2)설치
파이카메라 활용강좌 : 라즈베리파이 Pi-cam V4L2(Video4Linux2) 설치
라즈베리파이 카메라 성능 테스트
How to install or upgrade UV4L on Raspbian (for the Raspberry Pi)

Pi-Camera 활성화

$ sudo raspi-config

Pi-Camera 캡쳐

$ raspistill -v -o test.jpg
 
raspistill Camera App v1.3.11
 
Width 2592, Height 1944, quality 85, filename test.jpg
Time delay 5000, Raw no
Thumbnail enabled Yes, width 64, height 48, quality 35
Link to latest frame enabled  no
Full resolution preview No
Capture method : Single capture
 
Preview Yes, Full screen Yes
Preview window 0,0,1024,768
Opacity 255
Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Flicker Avoid Mode 'off'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
Camera component done
Encoder component done
Starting component connection stage
Connecting camera preview port to video render.
Connecting camera stills port to encoder input port
Opening output file test.jpg
Enabling encoder output port
Starting capture -1
Finished capture -1
Closing down
Close down completed, all components disconnected, disabled and destroyed

V4L2(Video4Linux2) 부팅시 활성화 시키기

$ sudo vi /etc/modules

아래 내용 추가

bcm2835-v4l2

확인

$ ls /dev/vi*
/dev/video0



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


출처

OS 이미지 다운로드

RASPBIAN 다운로드

OS 이미지 SD 메모리에 복사

SD 메모리 복사 프로그램인 Etcher를 이용해서 OS 이미지를 복사합니다.

버튼[Select image] 선택하고, 파일 선택 창에서 다운 받은 OS 이미지 선택

OS 이미지를 복사할 SD 메모리 선택하기 위해서 버튼[Select drive] 선택

OS 이미지를 복사할 SD 메모리 선택

버튼[Flash!] 선택해서 복사 시작

복사 시작 화면

복사중 화면

복사 완료 화면

한글폰트 설치

$ sudo apt-get install fonts-unfonts-core

한글 폰트 설치후 재부팅

$ sudo shutdown -r now

SSH 데몬 활성화

raspi-config 실행

$ sudo raspi-config

[Interfacing Options] 선택

[SSH] 선택

<예> 버튼 선택

<확인> 버튼 선택



라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.


기존 라즈베리파이3+

기존 라즈베리파이3 보다 개선된 라즈베리파이3+ 를 구입할까 고민하다가 아이씨뱅큐 무상 체험단이 되어 개봉기를 작성합니다. 최근에 나온 SBC 계열중에서 성능이 좋은 제품도 많이 있지만 라즈베리파이 만큼 호환성이나 자료가 많이 공개 된것은 없을 겁니다.

출처

개봉전 박스

라즈베리파이 3 Model B+

Raspberry Pi 3 케이스에 장착

스펙

  • Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
  • 1GB LPDDR2 SDRAM
  • 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2, BLE
  • Gigabit Ethernet over USB 2.0 (maximum throughput 300 Mbps)
  • Extended 40-pin GPIO header
  • Full-size HDMI
  • 4 USB 2.0 ports
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • 4-pole stereo output and composite video port
  • Micro SD port for loading your operating system and storing data
  • 5V/2.5A DC power input
  • Power-over-Ethernet (PoE) support (requires separate PoE HAT)

이전 버전과 스펙 비교

  • CPU : 17% 성능 향상 (1.2GHz - > 1.4GHz)
  • WiFi : 5G 추가 지원
  • BLE : 4.2 지원 ( BLE 4.1 -> BLE 4.2 )


라즈베리파이3 Model B+ 공식 구입처 : 아이씨뱅큐 http://www.icbanq.com/
마이크로비트 공식 카페 : http://cafe.naver.com/bbcmicro
아이씨뱅큐 공식 블로그 : http://blog.naver.com/icbanq

728x90
728x90

출처

Qt5 설치

$ sudo apt-get update
$ sudo apt-get install qt5-default qtbase5-dev qtdeclarative5-dev qt5-qmake qtcreator libqt5gui5  qtscript5-dev qtmultimedia5-dev libqt5multimedia5-plugins qtquickcontrols2-5-dev libqt5network5 cmake build-essential 
$ sudo apt-get install libqt5svg5-dev

oscpack 라이브러리

oscpack 라이브러리 다운로드

$ git clone https://github.com/dimitry-ishenko-casparcg/oscpack.git
Cloning into 'oscpack'...
remote: Counting objects: 511, done.
remote: Total 511 (delta 0), reused 0 (delta 0), pack-reused 511
Receiving objects: 100% (511/511), 110.97 KiB | 0 bytes/s, done.
Resolving deltas: 100% (377/377), done.

oscpack 라이브러리 설치

$ cd oscpack
$ make
$ sudo make install
install -c -D -m 755 liboscpack.so.1.1.0 //usr/local/lib/liboscpack.so.1.1.0
ln -s -f liboscpack.so.1.1.0 //usr/local/lib/liboscpack.so
mkdir -p //usr/local/include/ip //usr/local/include/osc
install -c -D -m 644 ip/*.h //usr/local/include/ip
install -c -D -m 644 osc/*.h //usr/local/include/osc
SUCCESS! oscpack has been installed in //usr/local/lib and //usr/local/include/ospack/

QT예제 - timer 프로그램

timer 프로그램 컴파일

$ git clone https://github.com/dimitry-ishenko-casparcg/timer.git
$ cd timer
$ qmake
$ ls
Makefile  README.md  res  screenshot.png  src  timer.pro
$ make

timer 프로그램 실행

$ ./timer

728x90

+ Recent posts