728x90
728x170

출처 : http://storefarm.naver.com/ic11401/products/570949799?NaPm=ct%3Dj3el6j5s%7Cci%3D81a1a50cfb607719908b7e825ff544963e247ce1%7Ctr%3Dsls%7Csn%3D434525%7Chk%3Db15e520415559b12b1b51e0687ee1a458548fcfa

 

* Specs

Operating voltage: 2.5V - 12V(cannot over 12V)

Working current: 18mA - 20mA at 5V

Output electrical level signal: low level when detecting objects / high level when no objects / 0 or 1 decides if objects exist.


* Contents

- Connect

GND ----- GND

OUT ----- D2

VCC ----- 5V


- Key Code

#include <Wire.h> 

#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27,20,4);  // LCD2004


int T = 2; // INPUT PIN

int count = 0;

String dot = ".";


void setup()

{

  lcd.init();  // initialize the lcd 

  lcd.backlight();

  lcd.print("start LCD2004");


  pinMode(T, INPUT);

  delay(1000);


  lcd.clear();

}


void loop()

{


  if(count >= 20)

  {

    dot = "";

    lcd.clear();

    count = 0;

  }

 

  lcd.setCursor(0,0);

  lcd.print("S026:KY-033 Tracking");


  if (LOW == digitalRead(T))

  {

    dot += "Detected";


    lcd.setCursor(0,1);

    lcd.print(dot);

    count = count+8;

  }

  else

  {

    dot += ".";

    lcd.setCursor(0,1);

    lcd.print(dot);

    count++;

  }

  delay(100);


}



출처: http://rdiot.tistory.com/168 [RDIoT Demo]

728x90
그리드형
Posted by kjun
,