i have been working on a temperature sensor project as one of my first big projects with Arduino. i want to read one of the one wire temperature sensors and based on what i set in an if statement be able to make the LED glow red, green, or blue. Here is what i came up with. in the if statement it replies "Thermistor1 cannot be used as a function", "ISO C++ forbids comparison between pointer and integer". Thanks to any one that replies for help!
#include <OneWire.h>
#include <DallasTemperature.h>
// 1 wire data pin 3
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Thermistor1 = { 0x28, 0x6A, 0x15, 0x41, 0x05, 0x00, 0x00, 0xE6 };
DeviceAddress Thermistor2 = { 0x28, 0xD0, 0xB1, 0x40, 0x05, 0x00, 0x00, 0x8D };
DeviceAddress Thermistor3 = { 0x28, 0xF2, 0x96, 0x40, 0x05, 0x00, 0x00, 0xFC };
DeviceAddress Thermistor4 = { 0x28, 0x37, 0xB6, 0x40, 0x05, 0x00, 0x00, 0x70 };
DeviceAddress Thermistor5 = { 0x28, 0x8A, 0x1E, 0x41, 0x05, 0x00, 0x00, 0xBF };
int R = 2;
int G = 3;
int B = 4;
void setup(void)
{
// Start serial port
Serial.begin(9600);
// Start the library
sensors.begin();
// Sets the resolution to 12 bit
sensors.setResolution(Thermistor1, 12);
sensors.setResolution(Thermistor2, 12);
sensors.setResolution(Thermistor3, 12);
sensors.setResolution(Thermistor4, 12);
sensors.setResolution(Thermistor5, 12);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature");
}
else
{
Serial.print("F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
}
void loop(void)
{
delay(5000);
Serial.print("Getting temperature...\n\r");
sensors.requestTemperatures();
Serial.print("Thermistor 1 temperature is: ");
printTemperature(Thermistor1);
Serial.print("\n\r");
Serial.print("Thermistor 2 temperature is: ");
printTemperature(Thermistor2);
Serial.print("\n\r");
Serial.print("Thermistor 3 temperature is: ");
printTemperature(Thermistor3);
Serial.print("\n\r");
Serial.print("Thermistor 4 temperature is: ");
printTemperature(Thermistor4);
Serial.print("\n\r");
Serial.print("Thermistor 5 temperature is: ");
printTemperature(Thermistor5);
Serial.print("\n\r\n\r");
if (Thermistor1 > 78)
{
digitalWrite(R, HIGH);
}
else
{
digitalWrite(R, LOW);
}
if (Thermistor1 == 78)
{
digitalWrite(G, HIGH);
}
else
{
digitalWrite(G, LOW);
}
if (Thermistor1 < 78)
{
digitalWrite(B, HIGH);
}
else
{
digitalWrite(B, LOW);
}
}