Stap 3: Code
Hier is de code kan worden uitgevoerd de Arduino:
Kopiëren/plakken zou moeten werken.
//Libraires #include <LiquidCrystal.h> #include <DallasTemperature.h> #include <OneWire.h> //Pinout lcd(RS, E, D4, D5, D6, DlcdLight) LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //DS18B20 signal pin to Arduino pin 6 #define ONE_WIRE_BUS 6 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); //Character for small "C", for Celcius, remove "/*"'s and delete the "F" /*byte customChar[8] = { 0b11100, 0b10000, 0b11100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000 }; */ //Custom character for small "F" byte customChar[8] = { 0b11100, 0b10000, 0b11000, 0b10000, 0b00000, 0b00000, 0b00000, 0b00000 }; const int lcdLight=7; void setup() { pinMode(lcdLight,OUTPUT); //Init sensor and lcd sensors.begin(); lcd.createChar(1,customChar); lcd.begin(16, 2); lcd.print("Temperature:"); lcd.setCursor(9,1); lcd.print("\337"); lcd.write(1); } void loop() { digitalWrite(lcdLight,HIGH); sensors.requestTemperatures(); lcd.setCursor(5,1); //Change the "F" to a "C" to switch to Celcius instead lcd.print(sensors.getTempFByIndex(0),1); delay(1000); }