Notice
Recent Posts
Recent Comments
Today
Total
05-16 00:00
Archives
관리 메뉴

Jeongchul Kim

Intel Edison board Eclipse Java LED 제어하기 본문

사물인터넷

Intel Edison board Eclipse Java LED 제어하기

김 정출 2016. 3. 8. 15:23


Intel Edison board Eclipse Java LED 제어하기



Window 메뉴에서 Show View 를 선택하여 Other를 누른다.

Intel(R) Iot Developer Kit에 Examples를 선택한다.



Java에 Basic에 On board Led blink를 선택한다.

import를 누른다.


프로젝트 이름을 기입하여 생성한다.


Java 소스는 이렇다.


import mraa.Dir;

import mraa.Gpio;

import mraa.Platform;

import mraa.Result;

import mraa.mraa;

public class Javaledblink2{

  static {

      System.loadLibrary("mraajava");

  }

  public static void main(String[] args) {

      // select onboard LED pin based on the platform type

      // create a GPIO object from MRAA using it

      Platform platform = mraa.getPlatformType();

      Gpio pin = null;

      if (platform == Platform.INTEL_GALILEO_GEN1)

          pin = new Gpio(3);

      else if (platform == Platform.INTEL_GALILEO_GEN2)

          pin = new Gpio(13);

      else if (platform == Platform.INTEL_EDISON_FAB_C)

          pin = new Gpio(13);

      // set the pin as output

      if (pin == null) {

          System.err.println("Could not initialize GPIO, exiting");

          return;

      }

      if (pin.dir(Dir.DIR_OUT) != Result.SUCCESS) {

          System.err.println("Could not set pin as output, exiting");

          return;

      }

      // loop forever toggling the on board LED every second

      while (true) {

          pin.write(0);

          try {

              Thread.sleep(1000);

          } catch (InterruptedException e) {

              System.err.println("Sleep interrupted: " + e.toString());

          }

          pin.write(1);

          try {

              Thread.sleep(1000);

          } catch (InterruptedException e) {

              System.err.println("Sleep interrupted: " + e.toString());

          }

      }

  }

}


Run 버튼을 통해 실행을 확인한다.



Comments