Arduino 예제 – cds + 캐릭터 lcdArduino Uno2015. 1. 20. 22:51
Table of Contents
반응형
불을 끄면 CDS값이 50이하로 떨어지고 LCD화면에 plz turn on을 출력합니다.
다시 불을 켜면 cds값은 올라가게 되고 LCD화면에 plz turn off를 출력합니다.
한줄만 지우는 방법을 못찾아서 약간 깜박입니다.
소스코드
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- int cdsPIN = 0;
- int ledPIN = 6;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- lcd.begin(16,2);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- int value = analogRead(cdsPIN);
- if ( value < 50 )
- {
- lcd.setCursor(0,0);
- lcd.print( " ");
- lcd.setCursor(0,0);
- lcd.print( "plz turn on" );
- }
- else
- {
- lcd.setCursor(0,0);
- lcd.print( " ");
- lcd.setCursor(0,0);
- lcd.print( "plz turn off" );
- }
- //cds값 출력
- lcd.setCursor(0,1);
- lcd.print( "000" );
- lcd.setCursor(0,1);
- lcd.print( value );
- delay(10);
- }
참고
반응형
'Arduino Uno' 카테고리의 다른 글
아두이노 튜토리얼 7 - Blink Without Delay (0) | 2015.02.11 |
---|---|
아듀이노 튜토리얼 6 - Analog Read Voltage (0) | 2015.02.11 |
아두이노 시리얼 명령으로 LED 켜고 끄기 (1) | 2015.01.20 |
아두이노에서 PWM을 이용하여 LED 밝기 조정하기 (0) | 2014.12.17 |
아두이노 예제 - 풀다운 저항과 버튼 (0) | 2014.12.09 |