Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //include LCD library
- #include <LiquidCrystal.h>
- //LCD pins
- LiquidCrystal lcd(7,6,5,4,3,2);
- //light sensor input pin
- const int lightPin = 0;
- //heat sensor input pin
- const int heatPin = 1;
- //record light level
- int lightLevel;
- //used to get heat level\
- float voltage, degreesC;
- void setup()
- {
- Serial.begin(9600);
- // LCD initial setups
- lcd.begin(16, 2);
- lcd.clear();
- }
- void loop()
- {
- // Begin
- float voltage, degreesC;
- // take Light reading as variable
- lightLevel = analogRead(lightPin);
- // take Heat level as voltage and convert to Celcius
- voltage = getVoltage(heatPin);
- degreesC = (voltage - 0.5) * 100.0;
- // display Heat + Light variables on LCD
- //serial display
- Serial.println(lightLevel);
- Serial.println(degreesC, 2);
- //lcd display
- lcd.setCursor(1,0);
- lcd.print("Temp: ");
- lcd.setCursor(7,0);
- lcd.print(degreesC,2);
- lcd.setCursor(1,1);
- lcd.print("Light: ");
- lcd.setCursor(8,1);
- lcd.print(lightLevel);
- // append values to txt file on computer via usb connection
- // wait specified time before taking next value
- delay(10000);
- }
- float getVoltage(int pin)
- {
- return (analogRead(pin) * 0.004882814);
- // This equation converts the 0 to 1023 value that analogRead()
- // returns, into a 0.0 to 5.0 value that is the true voltage
- // being read at that pin.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement