/* * 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 int inputReed = PBPIN4; int outputLED = PBPIN6; int value = 0; int debounce = 0; void setup() { Serial.begin(9600); pinMode(inputReed, INPUT); pinMode(outputLED, OUTPUT); } int getSamples(){ Serial.print("1"); Serial.print("\t"); Serial.print(TempSense.getTemp(CELSIUS)); Serial.println(); // switchtime of reed is 18 ms including debouncing... value = digitalRead(inputReed); delay(20); debounce = digitalRead(inputReed); if (value==debounce) { if (value == HIGH) { Serial.println("HIGH"); return 1; } else { Serial.println("LOW"); return 0; } } } void loop() { TempSense.overSample = true; if(getSamples()==1) { digitalWrite(outputLED, HIGH); } else { digitalWrite(outputLED, LOW); } delay(100); }