Devices & Components
Arduino Uno Rev3
MCP9808 High Accuracy I2C Temperature Sensor Breakout Board
Standard LCD - 16x2 White on Blue
Project description
Code
LCD_Thermometer
arduino
Makes use of both the LCD and temperature sensor libraries (MCP9808).
1#include <Adafruit_MCP9808.h> 2#include <LiquidCrystal.h> 3#include <Wire.h> 4 5Adafruit_MCP9808 tempsensor = Adafruit_MCP9808(); 6LiquidCrystal lcd(1,2,4,5,6,7); 7 8void setup() { 9 if (!tempsensor.begin()) { 10 while (1); 11 } 12 lcd.begin(16,2); 13 lcd.setCursor(0,0); 14} 15void loop() { 16 float c = tempsensor.readTempC(); 17 float f = c * 9.0 / 5.0 + 32; 18 19 lcd.setCursor(4,0); 20 lcd.print(f); 21 lcd.print(" F"); 22 23 lcd.setCursor(4,1); 24 lcd.print(c); 25 lcd.print(" C"); 26 27 delay(1000); 28 lcd.clear(); 29}
Comments
Only logged in users can leave comments