South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #15 on: February 28, 2012, 12:46:48 pm » |
This just screams "array and for loop"
I know I was trying for most of the day Sunday but could not get anything that would compile let alone work 
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #16 on: February 29, 2012, 07:05:40 am » |
Anyone care to advise?
Thanks
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #17 on: February 29, 2012, 07:20:16 am » |
Anyone care to advise? Same advice I always give. Show what you have tried, and describe the problems/show the error messages.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 143
Posts: 19366
I don't think you connected the grounds, Dave.
|
 |
« Reply #18 on: February 29, 2012, 07:31:02 am » |
const int sensorPins [] = {out, hall, bed, bath, lounge, kitchen};
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #19 on: February 29, 2012, 09:19:51 am » |
I'm really confused with this. Where do I reference to 'sensorPins'? I don't understand how to implement this into an array, I have just messed it up again  // Temperature measurement and averaging part uint8_t i; float average1 = 0; //input1 float average2 = 0; //input2 float average3 = 0; //input3 float average4 = 0; //input4 float average5 = 0; //input5 float average6 = 0; //input6 for (i=0; i< NUMSAMPLES; i++) { average1 += analogRead(out); average2 += analogRead(hall); average3 += analogRead(bed); average4 += analogRead(bath); average5 += analogRead(lounge); average6 += analogRead(kitchen); delay(10); } for (i=0; i< 6; I++) { average1 /= NUMSAMPLES; average2 /= NUMSAMPLES; average3 /= NUMSAMPLES; average4 /= NUMSAMPLES; average5 /= NUMSAMPLES; average6 /= NUMSAMPLES; }
double outTemp = convert(average1); double hallTemp = convert(average2); double bedTemp = convert(average3); double bathTemp = convert(average4); double loungeTemp = convert(average5); double kitchenTemp = convert(average6);
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 143
Posts: 19366
I don't think you connected the grounds, Dave.
|
 |
« Reply #20 on: February 29, 2012, 09:42:25 am » |
for (i=0; i< NUMSAMPLES; i++) { for (j = 0; j < sizeof (sensorPins) / sizeof (sensorPins [0]); j++) average[j] += analogRead(sensorPins[j]); } } If you wish, you can transpose the for loops, but this affects the order in which you sample the pins
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #21 on: February 29, 2012, 01:00:55 pm » |
Ah right, thanks Awol - I can follow some of that I think. Would this be the order in which they read? const int sensorPins [] = {out, hall, bed, bath, lounge, kitchen}; And I would have to declare the 'sizeof' the array? how would I then pull the value that has been averaged to be used elsewhere in the program? Thanks for the help 
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #22 on: February 29, 2012, 01:20:51 pm » |
Would this be the order in which they read? Yes. And I would have to declare the 'sizeof' the array? No. sizeof() is a function that returns that size of whatever is in the parentheses. In this case, it is determining how many bytes the array occupies, then dividing that by the size of one element of the array, to determine the number of elements in the array (so you don't have to).
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #23 on: March 01, 2012, 06:26:38 pm » |
trying to make it work with the array tonight. No success sadly. I am getting lots of errors on compile. /* The circuit: * LDR connected to analog pin 0. * LED / transistor connected from digital pin 3 to ground * LCD RS pin to digital pin 7 * LCD EN pin to digital pin 8 * LCD D4 pin to digital pin 9 * LCD D5 pin to digital pin 10 * LCD D6 pin to digital pin 11 * LCD D7 pin to digital pin 12 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) * LCD LED+ (15) pin transistor * LCD LED- (16) to ground * Thermisor divider 1 output to analog pin 1 * Thermisor divider 2 output to analog pin 2 */
// These constants won't change. They're used to give names // to the pins used: const int tempSelectPot = A0; // Analog input pin that the temp select pot is attached to const int LDRPin = A1; // Analog input pin that the lDR is attached to const int LCDBackLight = 3; // Analog (PWM) output pin that the BACKLIGHT is attached to const int coldPin = 2; // Digital output pin that the COLD RELAY is attached to const int frostPin = 4; // Digital output pin that the frost warning is attached to //const int hotPin = 5; // Digital output pin that the HOT LED is attached to const int out = A2; // Analog input that the 'Out' thermistor is connected too const int hall = A3; // Analog input that the 'Hall' thermistor is connected too const int bed = A4; // Analog input that the 'Bed' thermistor is connected too const int bath = A5; // Analog input that the 'Bath' thermistor is connected too const int lounge = A6; // Analog input that the 'Lounge' thermistor is connected too const int kitchen = A7; // Analog input that the 'Kitchen' thermistor is connected too const int modeButton = 6; //Digital input that the mode button is connected too
const int sensorPins [] = {out, hall, bed, bath, lounge, kitchen};
//floating point values float averageTemp = 0; //place to store average reading float desired = 0; //place to store selected mode
//Parameters**************
//const int hotTemp = 20; // upper do something threshold in degrees c const int setPointLow = 5; // lowest desired temp available to select in degrees c const int setPointHigh = 25; // highest desired temp available to select in degrees c const int frostWarning = 5; // outside frost warning LED on threshold in degrees c float hysteresis = 0.4; // Temperature error switching margin to avoid rapid activation in degrees c
const int minLight = 80; // at or below this light level, use minimum backlight intensity const int maxLight = 920; // at or above this light level, use maximum backlight intensity const int minBacklight = 10; // lowest backlight intensity to use const int maxBacklight = 255; // highest backlight intensity to use
// include the library code: #include <LiquidCrystal.h> #include <math.h>
#define NUMSAMPLES 32 // Number of analog samples to take
double convert(double RawADC) { double Temp; Temp = log(((10240000/RawADC) - 10000)); Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ); Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp; }
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int potRead = 0; // value read from the pot int LDRRead = 0; // value read from the LDR int outputValue = 0; // value output to the PWM (analog out) int setPoint = 0; // value set point
void setup() { lcd.begin(20, 4); delay(100); //Declare pin modes pinMode(3, OUTPUT); //LCD BACKLIGHT pinMode(coldPin, OUTPUT); //COLD WARNING pinMode(frostPin, OUTPUT); //OUTSIDE FROST WARNING pinMode(modeButton, INPUT); //MODE SELECT BUTTON digitalWrite(modeButton, HIGH); //set input button to 5v to use internal pull up }
void loop() { // LDR controlled LCD backlight via PWM part int sum = 0; for (int i=0; i<16; i++) // take 16 samples from the analog input { sum += analogRead(LDRPin); } LDRRead = sum/16; // divide by the amount of samples for the average value
// map it to the range[0..255] of the analog output that the LCD backlight it connected to outputValue = LDRRead/4; // alternative to map function for scaling down from analog input outputValue = map(constrain(LDRRead, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );
// change the analog out value to adjust LCD backlight intensity analogWrite(LCDBackLight, outputValue);
// Desired temperature selection via potentiometer part potRead = analogRead(tempSelectPot); setPoint = map (potRead, 0, 1023, setPointLow, setPointHigh);
// Temperature measurement and averaging part uint8_t i; float average1 = 0; //input1 float average2 = 0; //input2 float average3 = 0; //input3 float average4 = 0; //input4 float average5 = 0; //input5 float average6 = 0; //input6 for (i=0; i< NUMSAMPLES; i++) { for (j = 0; j < sizeof (sensorPins) / sizeof (sensorPins [0]); j++) average[j] += analogRead(sensorPins[j]); } }
double outTemp = convert(average1); double hallTemp = convert(average2); double bedTemp = convert(average3); double bathTemp = convert(average4); double loungeTemp = convert(average5); double kitchenTemp = convert(average6);
//THERMOSTAT DUTIES digitalRead(modeButton); delay(100); //some bebounce time desired = digitalRead(modeButton); //Clear the LCD ready for fresh data to be printed lcd.clear();
if(desired == HIGH) { lcd.setCursor(19,4); lcd.print((char)165); } else if(desired == LOW) { lcd.setCursor(19,4); lcd.print((char)219); }
if(desired == HIGH && hallTemp <setPoint - hysteresis) { digitalWrite(coldPin, HIGH); // set the LED on } else if (desired == HIGH && hallTemp >setPoint + hysteresis) { digitalWrite(coldPin, LOW); // set the LED off } else if (desired == LOW && averageTemp <setPoint + hysteresis) { digitalWrite(coldPin, HIGH); // set the LED off } else if (desired == LOW && averageTemp >setPoint + hysteresis) { digitalWrite(coldPin, LOW); // set the LED off }
//Print desired set point temp to LCD lcd.setCursor(11,4); lcd.print ("Set: ");
if(setPoint <setPointLow +1) lcd.print((char)42); // print symbol for frost protection setting else if (setPoint >setPointLow) lcd.print(setPoint);
//Print average temp to LCD averageTemp = hallTemp + bedTemp + bathTemp + loungeTemp + kitchenTemp; // temp zones to take average from averageTemp = averageTemp/5; // divide by number of temp zones to get average
lcd.setCursor(11,2); lcd.print ("Ave: "); lcd.print(averageTemp, 1); //lcd.print((char)223); //lcd.print ("c"); //Print hall temp to LCD lcd.setCursor(0,0); lcd.print ("Hal: "); lcd.print(hallTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print lounge temp to LCD lcd.setCursor(11,0); lcd.print ("Lng: "); lcd.print(loungeTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print kitchen temp to LCD lcd.setCursor(0,1); lcd.print ("Kit: "); lcd.print(kitchenTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print bedroom temp to LCD lcd.setCursor(11,1); lcd.print ("Bed: "); lcd.print(bedTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print bathroom temp to LCD lcd.setCursor(0,2); lcd.print ("Bth: "); lcd.print(bathTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print outside temp to LCD lcd.setCursor(0,4); lcd.print ("Out: "); lcd.print(outTemp, 1); //lcd.print((char)223); //lcd.print ("c");
// Exterior frost warning LED part if(outTemp <frostWarning - hysteresis) digitalWrite(frostPin, HIGH); // set the LED on else if (outTemp >frostWarning + hysteresis) digitalWrite(frostPin, LOW); // set the LED off
delay(900); }
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #24 on: March 01, 2012, 06:26:49 pm » |
errors Thermostat_Release_1_0.cpp: In function 'void loop()': Thermostat_Release_1_0:131: error: 'j' was not declared in this scope Thermostat_Release_1_0:132: error: 'average' was not declared in this scope Thermostat_Release_1_0.cpp: At global scope: Thermostat_Release_1_0:136: error: 'average1' was not declared in this scope Thermostat_Release_1_0:137: error: 'average2' was not declared in this scope Thermostat_Release_1_0:138: error: 'average3' was not declared in this scope Thermostat_Release_1_0:139: error: 'average4' was not declared in this scope Thermostat_Release_1_0:140: error: 'average5' was not declared in this scope Thermostat_Release_1_0:141: error: 'average6' was not declared in this scope Thermostat_Release_1_0:147: error: expected constructor, destructor, or type conversion before '(' token Thermostat_Release_1_0:148: error: expected constructor, destructor, or type conversion before '(' token Thermostat_Release_1_0:149: error: expected constructor, destructor, or type conversion before '=' token Thermostat_Release_1_0:152: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:154: error: expected unqualified-id before 'if' Thermostat_Release_1_0:159: error: expected unqualified-id before 'else' Thermostat_Release_1_0:169: error: expected unqualified-id before 'if' Thermostat_Release_1_0:173: error: expected unqualified-id before 'else' Thermostat_Release_1_0:177: error: expected unqualified-id before 'else' Thermostat_Release_1_0:181: error: expected unqualified-id before 'else' Thermostat_Release_1_0:188: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:189: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:191: error: expected unqualified-id before 'if' Thermostat_Release_1_0:193: error: expected unqualified-id before 'else' Thermostat_Release_1_0:198: error: expected constructor, destructor, or type conversion before '=' token Thermostat_Release_1_0:199: error: expected constructor, destructor, or type conversion before '=' token Thermostat_Release_1_0:201: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:202: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:203: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:208: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:209: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:210: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:215: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:216: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:217: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:222: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:223: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:224: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:229: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:230: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:231: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:236: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:237: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:238: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:243: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:244: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:245: error: expected constructor, destructor, or type conversion before '.' token Thermostat_Release_1_0:251: error: expected unqualified-id before 'if' Thermostat_Release_1_0:253: error: expected unqualified-id before 'else' Thermostat_Release_1_0:258: error: expected constructor, destructor, or type conversion before '(' token Thermostat_Release_1_0:259: error: expected declaration before '}' token
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 226
Posts: 14101
Lua rocks!
|
 |
« Reply #25 on: March 01, 2012, 07:35:23 pm » |
Too many RH braces here, for a start: for (i=0; i< NUMSAMPLES; i++) { for (j = 0; j < sizeof (sensorPins) / sizeof (sensorPins [0]); j++) average[j] += analogRead(sensorPins[j]); } } What AWOL means is to change: float average1 = 0; //input1 float average2 = 0; //input2 float average3 = 0; //input3 float average4 = 0; //input4 float average5 = 0; //input5 float average6 = 0; //input6
to: float average [6] = 0; Then the loop will iterate over all 6 averages (numbered 0 to 5);
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #26 on: March 01, 2012, 08:02:32 pm » |
Thanks Nick, I have just tried to implement those changes but still getting multiple compile errors  Not quite sure where i'm going wrong, confused as to why i'm getting errors about things not being declared? /* The circuit: * LDR connected to analog pin 0. * LED / transistor connected from digital pin 3 to ground * LCD RS pin to digital pin 7 * LCD EN pin to digital pin 8 * LCD D4 pin to digital pin 9 * LCD D5 pin to digital pin 10 * LCD D6 pin to digital pin 11 * LCD D7 pin to digital pin 12 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) * LCD LED+ (15) pin transistor * LCD LED- (16) to ground * Thermisor divider 1 output to analog pin 1 * Thermisor divider 2 output to analog pin 2 */
// These constants won't change. They're used to give names // to the pins used: const int tempSelectPot = A0; // Analog input pin that the temp select pot is attached to const int LDRPin = A1; // Analog input pin that the lDR is attached to const int LCDBackLight = 3; // Analog (PWM) output pin that the BACKLIGHT is attached to const int coldPin = 2; // Digital output pin that the COLD RELAY is attached to const int frostPin = 4; // Digital output pin that the frost warning is attached to //const int hotPin = 5; // Digital output pin that the HOT LED is attached to const int out = A2; // Analog input that the 'Out' thermistor is connected too const int hall = A3; // Analog input that the 'Hall' thermistor is connected too const int bed = A4; // Analog input that the 'Bed' thermistor is connected too const int bath = A5; // Analog input that the 'Bath' thermistor is connected too const int lounge = A6; // Analog input that the 'Lounge' thermistor is connected too const int kitchen = A7; // Analog input that the 'Kitchen' thermistor is connected too const int modeButton = 6; //Digital input that the mode button is connected too
const int sensorPins [] = {out, hall, bed, bath, lounge, kitchen};
//floating point values float averageTemp = 0; //place to store average reading float desired = 0; //place to store selected mode
//Parameters**************
//const int hotTemp = 20; // upper do something threshold in degrees c const int setPointLow = 5; // lowest desired temp available to select in degrees c const int setPointHigh = 25; // highest desired temp available to select in degrees c const int frostWarning = 5; // outside frost warning LED on threshold in degrees c float hysteresis = 0.4; // Temperature error switching margin to avoid rapid activation in degrees c
const int minLight = 80; // at or below this light level, use minimum backlight intensity const int maxLight = 920; // at or above this light level, use maximum backlight intensity const int minBacklight = 10; // lowest backlight intensity to use const int maxBacklight = 255; // highest backlight intensity to use
// include the library code: #include <LiquidCrystal.h> #include <math.h>
#define NUMSAMPLES 32 // Number of analog samples to take
double convert(double RawADC) { double Temp; Temp = log(((10240000/RawADC) - 10000)); Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ); Temp = Temp - 273.15; // Convert Kelvin to Celcius
return Temp; }
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int potRead = 0; // value read from the pot int LDRRead = 0; // value read from the LDR int outputValue = 0; // value output to the PWM (analog out) int setPoint = 0; // value set point
void setup() { lcd.begin(20, 4); delay(100); //Declare pin modes pinMode(3, OUTPUT); //LCD BACKLIGHT pinMode(coldPin, OUTPUT); //COLD WARNING pinMode(frostPin, OUTPUT); //OUTSIDE FROST WARNING pinMode(modeButton, INPUT); //MODE SELECT BUTTON digitalWrite(modeButton, HIGH); //set input button to 5v to use internal pull up }
void loop() { // LDR controlled LCD backlight via PWM part int sum = 0; for (int i=0; i<16; i++) // take 16 samples from the analog input { sum += analogRead(LDRPin); } LDRRead = sum/16; // divide by the amount of samples for the average value
// map it to the range[0..255] of the analog output that the LCD backlight it connected to outputValue = LDRRead/4; // alternative to map function for scaling down from analog input outputValue = map(constrain(LDRRead, minLight, maxLight), minLight, maxLight, minBacklight, maxBacklight );
// change the analog out value to adjust LCD backlight intensity analogWrite(LCDBackLight, outputValue);
// Desired temperature selection via potentiometer part potRead = analogRead(tempSelectPot); setPoint = map (potRead, 0, 1023, setPointLow, setPointHigh);
// Temperature measurement and averaging part
for (i=0; i< NUMSAMPLES; i++) { for (j = 0; j < sizeof (sensorPins) / sizeof (sensorPins [0]); j++) average[j] += analogRead(sensorPins[j]); } float average [6] = 0;
double outTemp = convert(average0); double hallTemp = convert(average1); double bedTemp = convert(average2); double bathTemp = convert(average3); double loungeTemp = convert(average4); double kitchenTemp = convert(average5);
//THERMOSTAT DUTIES digitalRead(modeButton); delay(100); //some bebounce time desired = digitalRead(modeButton); //Clear the LCD ready for fresh data to be printed lcd.clear();
if(desired == HIGH) { lcd.setCursor(19,4); lcd.print((char)165); } else if(desired == LOW) { lcd.setCursor(19,4); lcd.print((char)219); }
if(desired == HIGH && hallTemp <setPoint - hysteresis) { digitalWrite(coldPin, HIGH); // set the LED on } else if (desired == HIGH && hallTemp >setPoint + hysteresis) { digitalWrite(coldPin, LOW); // set the LED off } else if (desired == LOW && averageTemp <setPoint + hysteresis) { digitalWrite(coldPin, HIGH); // set the LED off } else if (desired == LOW && averageTemp >setPoint + hysteresis) { digitalWrite(coldPin, LOW); // set the LED off }
//Print desired set point temp to LCD lcd.setCursor(11,4); lcd.print ("Set: ");
if(setPoint <setPointLow +1) lcd.print((char)42); // print symbol for frost protection setting else if (setPoint >setPointLow) lcd.print(setPoint);
//Print average temp to LCD averageTemp = hallTemp + bedTemp + bathTemp + loungeTemp + kitchenTemp; // temp zones to take average from averageTemp = averageTemp/5; // divide by number of temp zones to get average
lcd.setCursor(11,2); lcd.print ("Ave: "); lcd.print(averageTemp, 1); //lcd.print((char)223); //lcd.print ("c"); //Print hall temp to LCD lcd.setCursor(0,0); lcd.print ("Hal: "); lcd.print(hallTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print lounge temp to LCD lcd.setCursor(11,0); lcd.print ("Lng: "); lcd.print(loungeTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print kitchen temp to LCD lcd.setCursor(0,1); lcd.print ("Kit: "); lcd.print(kitchenTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print bedroom temp to LCD lcd.setCursor(11,1); lcd.print ("Bed: "); lcd.print(bedTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print bathroom temp to LCD lcd.setCursor(0,2); lcd.print ("Bth: "); lcd.print(bathTemp, 1); //lcd.print((char)223); //lcd.print ("c");
//Print outside temp to LCD lcd.setCursor(0,4); lcd.print ("Out: "); lcd.print(outTemp, 1); //lcd.print((char)223); //lcd.print ("c");
// Exterior frost warning LED part if(outTemp <frostWarning - hysteresis) digitalWrite(frostPin, HIGH); // set the LED on else if (outTemp >frostWarning + hysteresis) digitalWrite(frostPin, LOW); // set the LED off
delay(900); }
|
|
|
|
|
Logged
|
|
|
|
|
Des Moines, WA - USA
Offline
God Member
Karma: 25
Posts: 746
|
 |
« Reply #27 on: March 01, 2012, 08:24:38 pm » |
It'd help if you had a variables named 'i' and 'j' or better yet do it this way! for ( int i = 0; i < NUMSAMPLES; i++ ) { for ( int j = 0; j < sizeof(sensorPins) / sizeof(sensorPins[0]); j++ ) { average[j] += analogRead(sensorPins[j]); } }
Code formatting, including brace placement, can make it easier to spot problems.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 491
|
 |
« Reply #28 on: March 02, 2012, 06:42:32 am » |
Hi, I still can't get it to compile  Now I get the error stating that average was not declared in this scope? Thermostat_Release_1_0.cpp: In function 'void loop()': Thermostat_Release_1_0:133: error: 'average' was not declared in this scope Thermostat_Release_1_0:136: error: array must be initialized with a brace-enclosed initializer
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 143
Posts: 19366
I don't think you connected the grounds, Dave.
|
 |
« Reply #29 on: March 02, 2012, 06:47:49 am » |
The error message is pretty self-explanatory, but if you want further help, you need to post the code that gave the error.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
|