/* * HotHotHeat * * Compile with the Arduino IDE (http://arduino.cc); is deployed against a * Atmel Butterfly - so you also need the Butteruino project * (http://code.google.com/p/butteruino/) * * ...will * 1) Read the Butterfly temperature sensor and output * the result permanently to UART. * * 2) Read a reed sensor and output * the result permanently to UART * * Contact: Norbert Wigbels * (http://foobla.wigbels.de/uber-foobla/) * * Format: <# of Sensor> * Example: 1; Temperature in Celsius * tbd. */ #include #include #include #include int inputReed = PBPIN4; int outputLED = PBPIN3; int value = 0; int debounce = 0; long gasReeds = 0; void setup() { LCD.prints_f(PSTR("HOTHOTHEAT")); delay(2500); // Set up the RTC timer to call the secTick() function every second. RTCTimer.init( secTick ); Serial.begin(9600); TempSense.overSample = true; pinMode(inputReed, INPUT); pinMode(outputLED, OUTPUT); } void secTick() { LCD.print( gasReeds ); LCD.println( " tGR" ); } int getSamples() { // Temperature = Sensor 1 Serial.print("1"); Serial.print("\t"); Serial.println(TempSense.getTemp(CELSIUS)); // switchtime of reed is 18 ms including debouncing... value = digitalRead(inputReed); delay(20); debounce = digitalRead(inputReed); // Reedcontact = Sensor 2 if (value==debounce) { Serial.print("2"); Serial.print("\t"); if (value == HIGH) { Serial.println("HIGH"); gasReeds++; return 1; } else { Serial.println("LOW"); return 0; } } } void loop() { // Switch LED on for a certain time to mark a switched Reed contact if(getSamples()==1) { digitalWrite(outputLED, HIGH); } else { digitalWrite(outputLED, LOW); } delay(100); }