I am trying to blink and LED one when the temperature is going up and twice when going down.I only got it to blink when it reads something but not differently .sketch below.
What did i do wrong?
Arduino Mega 2560 with max6675
#include <max6675.h>
// ThermoCouple
int thermo_gnd_pin = 45;
int thermo_vcc_pin = 47;
int thermo_so_pin = 53;
int thermo_cs_pin = 51;
int thermo_sck_pin = 49;
MAX6675 thermocouple(thermo_sck_pin, thermo_cs_pin, thermo_so_pin);
//value
int newval1 , oldval1;
void setup()
{
Serial.begin(9600);
pinMode(thermo_vcc_pin, OUTPUT);
pinMode(thermo_gnd_pin, OUTPUT);
digitalWrite(thermo_vcc_pin, HIGH);
digitalWrite(thermo_gnd_pin, LOW);
pinMode(13, OUTPUT);
}
void loop()
{
Serial.print("Temp: ");
Serial.println(thermocouple.readCelsius());
delay(1000);
if (newval1 > oldval1)
digitalWrite(LED_BUILTIN, HIGH);
delay(10);
if (newval1 < oldval1)
digitalWrite(LED_BUILTIN, HIGH);
delay(10);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
digitalWrite(LED_BUILTIN, HIGH);
delay(10);
digitalWrite(LED_BUILTIN, LOW);
}
[code]