Created
May 7, 2013 13:58
-
-
Save biskandar/5532777 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
const int lightPin = A0 ; // Light Sensor Pin | |
const int tempPin = A1 ; // Temperature Sensor Pin | |
const int lcdRSPin = 13 ; // Select Pin | |
const int lcdENPin = 12 ; // Enable Pin | |
const int lcdD4Pin = 11 ; // Databus line 4 | |
const int lcdD5Pin = 8 ; // Databus line 5 | |
const int lcdD6Pin = 7 ; // Databus line 6 | |
const int lcdD7Pin = 4 ; // Databus line 7 | |
const int lcdBLPin = 5 ; // Backlight Pin | |
LiquidCrystal lcd( lcdRSPin , lcdENPin , lcdD4Pin , lcdD5Pin , lcdD6Pin , lcdD7Pin ) ; | |
void setup() { | |
// setup sensors | |
pinMode( lightPin , INPUT ) ; | |
pinMode( tempPin , INPUT ) ; | |
// setup lcd | |
lcd.begin( 8 , 2 ) ; | |
// turn lcd backlight on | |
analogWrite( lcdBLPin , 255 ) ; | |
} | |
void loop() { | |
int lightAnalog = analogRead( lightPin ) ; | |
int tempAnalog = analogRead( tempPin ) ; | |
int lightPerc = map( lightAnalog , 0 , 1023 , 1 , 100 ) ; | |
int tempCalc = map( tempAnalog , 0 , 1023 , 0 , 499 ) - 50 ; | |
lcd.setCursor( 0 , 0 ) ; | |
lcd.print( "L: " ) ; | |
lcd.print( lightPerc ) ; | |
lcd.print( "%" ) ; | |
lcd.setCursor( 0 , 1 ) ; | |
lcd.print( "T: " ) ; | |
lcd.print( tempCalc ) ; | |
lcd.print( "C" ) ; | |
// delay 1000ms | |
delay( 1000 ) ; | |
// clear lcd | |
lcd.clear() ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment