thanks for the help, after I posted the code snippets i'd realized i probably could have just a easily posted the whole thing and been done with it. I had no idea there was an already built in pullup input.
like I mentioned i'm really just stabbing at the dark and googling as I go. I haven "coded" since BASIC in my pre-teens and Hypertalk in my teens. I attempted C later on but was just too much for me. Making sure all these braces are closed is killing me.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
#define THERMISTORPIN A0
#define THERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25
#define NUMSAMPLES 10
#define BCOEFFICIENT 3950
#define SERIESRESISTOR 10000
#define TEMPMIN 30
#define TEMPMAX 42
int TEMPSET = 35;
int VALDOWN = 0;
int VALUP = 0;
int LASTUP = 0;
int LASTDOWN = 0;
int L = 0;
const int relay =11;
uint16_t samples[NUMSAMPLES];
void setup()
{
pinMode(11, OUTPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
lcd.begin(16,2);
lcd.backlight();
lcd.clear();
}
void loop(void){
for (int L=0; L<100; L++){
uint8_t i;
float average;
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(THERMISTORPIN);
delay(10);
}
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
float celcius;
celcius = average / THERMISTORNOMINAL; // (R/Ro)
celcius = log(celcius); // ln(R/Ro)
celcius /= BCOEFFICIENT; // 1/B * ln(R/Ro)
celcius += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
celcius = 1.0 / celcius; // Invert
celcius -= 273.15; // convert to C
VALDOWN = digitalRead(4);
if (VALDOWN != LASTDOWN) {
if (VALDOWN == HIGH) {
TEMPSET -1;
} else {
VALDOWN = LASTDOWN;
}
delay(100);
}
VALUP = digitalRead(5);
if (VALUP != LASTUP) {
if (VALUP == HIGH) {
TEMPSET +1;
} else {
VALUP = LASTUP;
}
delay(100);
}
lcd.setCursor(0,0);
lcd.print("Temp ");
lcd.print (celcius);
lcd.print((char)223);
lcd.print("C ");
lcd.setCursor(0,1);
lcd.print("Set ");
lcd.print (TEMPSET);
lcd.print((char)223);
lcd.print("C");
if (celcius < TEMPSET) {
digitalWrite(11, HIGH);
} else {
digitalWrite(11, LOW);
}
}
}
once i can get the increment/decrement working i'll be setting a minimum and maximum and doing a check for it to make sure the TEMPSET value does not exceed or fall below the established minimum/maximum (in this case the low value of 30 and maximum of 42)