Hello everyone.
I have stitched this sketch together from two sketches that work on there own.
I keep getting an error that says "{" is not supposed to be there. In layman terms for you Gurus.
Here is the sketch.
/*
Demonstration sketch for Adafruit i2c/SPI LCD backpack
using MCP23008 I2C expander
( i2c/SPI LCD Backpack )
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
- 5V to Arduino 5V pin
- GND to Arduino GND pin
- CLK to Analog #5
- DAT to Analog #4
*/
// include the library code:
#include <Wire.h>
#include <LiquidTWI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
int tempPin = 0;
int lightPin = 1;
// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidTWI lcd(0);
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// Arduino 1-Wire Address Finder
DeviceAddress insideThermometer = { 0x28, 0x61, 0x40, 0x15, 0x06, 0x00, 0x00, 0x6B };
DeviceAddress outsideThermometer = { 0x28, 0x2E, 0x72, 0x48, 0x05, 0x00, 0x00, 0x9C };
//DeviceAddress dogHouseThermometer = { 0x28, 0x59, 0xBE, 0xDF, 0x02, 0x00, 0x00, 0x9F };
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
sensors.setResolution(outsideThermometer, 10);
//sensors.setResolution(dogHouseThermometer, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
void loop()
{
// Display Temperature in C
int tempReading = analogRead(tempPin);
float tempVolts = tempReading * 5.0 / 1024.0;
float tempC = (tempVolts - 0.5) * 100.0;
float tempF = tempC * 9.0 / 5.0 + 32.0;
// ----------------
lcd.setCursor(3, 0);
lcd.print("ROOM TEMP ");
lcd.setCursor(6,1);
lcd.print(tempF);
delay (5000);
lcd.clear();
// Display LIGHT SENSOR on first row
lcd.setCursor(2, 0);
lcd.print("LIGHT SENSOR");
// ----------------
int lightReading = analogRead(lightPin);
lcd.setCursor(7, 1);
lcd.print(lightReading);
delay(5000);
lcd.clear();
// Display Dallas TEMP 0 on first row
lcd.setCursor(3, 0);
lcd.print("Dallas TEMP 0 ");
printTemperature(insideThermometer);
lcd.setCursor(7, 1);
lcd.print(insideThermometer);
delay(5000);
lcd.clear();
// Display Dallas TEMP 1 on first row
lcd.setCursor(3, 0);
lcd.print("Dallas TEMP 1 ");
printTemperature(outsideThermometer);
lcd.setCursor(7, 1);
lcd.print(outsideThermometer);
delay(5000);
lcd.clear();
}
Can you see what I am not seeing and give my some guidance.
Thanks to all that reply.
onecansay.