I'm hoping to run it off batteries eventually. But anyway, here's some of the code I have at the moment:
const byte LED = 13;
const byte BUTTON = 2;
// Interrupt Service Routine (ISR)
void pinChange ()
{
Serial.println(millis());
if (digitalRead (BUTTON) == HIGH)
digitalWrite (LED, HIGH);
else
digitalWrite (LED, LOW);
} // end of pinChange
void setup ()
{
Serial.begin(9600);
pinMode (LED, OUTPUT); // so we can update the LED
digitalWrite (BUTTON, HIGH); // internal pull-up resistor
attachInterrupt (0, pinChange, CHANGE); // attach interrupt handler
} // end of setup
void loop ()
{
//Start Temperature Measurement:
int therm0 = analogRead(A0); //1. input on Analog pin 0
float volt0 = therm0 * (5 / 1023.0); //2. conversion to Voltage
float temp0 = ((volt0 + 10.281)/0.0458)-273.15; //3. temperature calc 0
int therm1 = analogRead(A1); //1. input on Analog pin 1
float volt1 = therm1 * (5 / 1023.0); //2. conversion to Voltage
float temp1 = ((volt1 + 10.281)/0.0458)-273.15; //3. temperature calc 1
Serial.println(temp1);
//End Temperature Measurement
}
Both the temperature measurement and the pin interrupt run okay by themselves, but when I try the above sketch with both of them in the same sketch. The void.Loop() runs continuously until the interrupt, after the interrupt it stops reporting the temperature to the serial out.