G2A Many GEOs
SHARE
TWEET

Biotope V1.1 DS18B20 + LDR + LCD I2C

mc_workshop Mar 12th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //BIOTOPE
  2. //MCWORKSHOP
  3. //DS18B20 + LDR + LCD I2C
  4. //temperature + light
  5. //marzo 2019 V1.1
  6. //This example code is in the public domain.
  7.  
  8. #include <OneWire.h>
  9. #include <Wire.h>
  10. #include <DallasTemperature.h>
  11. #define ONE_WIRE_BUS 14
  12. OneWire ourWire(ONE_WIRE_BUS);
  13. DallasTemperature sensors(&ourWire);
  14. #include <LiquidCrystal_I2C.h>
  15. #define DS1307_I2C_ADDRESS 0x27 // attenzione all'indirizzo dell'LCD
  16. LiquidCrystal_I2C lcd(0x27, 16, 2);
  17.  
  18. int analogInPin = A1;
  19. int sensorValue = 0;
  20.  
  21. void setup()
  22. {
  23.   Serial.begin(9600);
  24.   pinMode( analogInPin, INPUT);
  25.   lcd.init();
  26.   lcd.backlight();
  27.   lcd.begin (16, 2);
  28.   sensors.begin();
  29. }
  30. void loop()
  31. {
  32.   lcd.setCursor(0, 0);
  33.   sensors.requestTemperatures();
  34.   lcd.print("t H2O ");
  35.   lcd.print(sensors.getTempCByIndex(0));
  36.   lcd.print(" C    ");
  37.   sensorValue = analogRead(analogInPin);
  38.   sensorValue = map(sensorValue, 0, 1023, 0, 100);
  39.   lcd.setCursor(0, 1);
  40.   lcd.print ("light v. ");
  41.   lcd.print(sensorValue);
  42. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top