반응형

 

 

불을 끄면 CDS값이 50이하로 떨어지고 LCD화면에 plz turn on을 출력합니다.

다시 불을 켜면 cds값은 올라가게 되고 LCD화면에 plz turn off를 출력합니다.

한줄만 지우는 방법을 못찾아서 약간 깜박입니다.


 

 

소스코드

  1. #include <LiquidCrystal.h>  
  2.     
  3. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  
  4. int cdsPIN = 0;  
  5. int ledPIN = 6;  
  6.     
  7. void setup() {  
  8.   // put your setup code here, to run once:  
  9.   Serial.begin(9600);  
  10.   lcd.begin(16,2);  
  11. }  
  12.     
  13. void loop() {  
  14.   // put your main code here, to run repeatedly:   
  15.   int value = analogRead(cdsPIN);  
  16.       
  17.   if ( value < 50 )  
  18.   {  
  19.     lcd.setCursor(0,0);  
  20.     lcd.print( "                 ");  
  21.     lcd.setCursor(0,0);  
  22.     lcd.print( "plz turn on" );  
  23.   }  
  24.   else  
  25.   {  
  26.     lcd.setCursor(0,0);  
  27.     lcd.print( "                 ");  
  28.     lcd.setCursor(0,0);  
  29.     lcd.print( "plz turn off" );      
  30.   }  
  31.       
  32.   //cds 출력  
  33.   lcd.setCursor(0,1);  
  34.   lcd.print( "000" );  
  35.   lcd.setCursor(0,1);  
  36.   lcd.print( value );  
  37.   delay(10);  
  38. }  

 

 

참고

http://arduino.cc/en/Tutorial/LiquidCrystalSerial

http://playground.arduino.cc/Learning/PhotoResistor

문제 발생시 지나치지 마시고 댓글 남겨주시면 가능한 빨리 답장드립니다.


제가 쓴 책도 한번 검토해보세요 ^^

+ Recent posts