source: de.wigbels.avr/sketchbook/hothotheat/hothotheat.pde @ 71bba07

Last change on this file since 71bba07 was 71bba07, checked in by njw <njw@…>, 15 years ago

added some lcd-printouts for initial testing...

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 * HotHotHeat
3 *
4 * Compile with the Arduino IDE (http://arduino.cc); is deployed against a
5 * Atmel Butterfly - so you also need the Butteruino project
6 * (http://code.google.com/p/butteruino/)
7 *
8 * ...will
9 * 1) Read the Butterfly temperature sensor and output
10 * the result permanently to UART.
11 *
12 * 2) Read a reed sensor and output
13 * the result permanently to UART
14 *
15 * Contact: Norbert Wigbels
16 * (http://foobla.wigbels.de/uber-foobla/)
17 *
18 * Format: <# of Sensor> <data>
19 * Example: 1; Temperature in Celsius
20 * tbd.
21 */
22 
23#include <butterfly_temp.h>
24#include <pins_butterfly.h>
25
26#include <LCD_Driver.h>
27#include <timer2_RTC.h>
28
29
30int inputReed = PBPIN4;
31int outputLED = PBPIN3;
32
33int value = 0;
34int debounce = 0;
35
36long gasReeds = 0;
37
38void setup() {
39  LCD.prints_f(PSTR("HOTHOTHEAT"));
40  delay(2500);
41 
42  // Set up the RTC timer to call the secTick() function every second.
43  RTCTimer.init( secTick );
44 
45  Serial.begin(9600);
46
47  TempSense.overSample = true;
48
49  pinMode(inputReed, INPUT);
50  pinMode(outputLED, OUTPUT);
51}
52
53void secTick()
54{
55  LCD.print( gasReeds );
56  LCD.println( " tGR" );
57}
58
59int getSamples() {
60  // Temperature = Sensor 1
61  Serial.print("1");
62  Serial.print("\t");
63  Serial.println(TempSense.getTemp(CELSIUS));
64
65  // switchtime of reed is 18 ms including debouncing...
66  value = digitalRead(inputReed);
67  delay(20);
68  debounce = digitalRead(inputReed);
69
70  // Reedcontact = Sensor 2
71  if (value==debounce) {
72    Serial.print("2");
73    Serial.print("\t");
74    if (value == HIGH) {
75      Serial.println("HIGH");
76      gasReeds++;
77      return 1;
78    }
79    else {
80      Serial.println("LOW");
81      return 0;
82    }
83  }
84}
85
86void loop() { 
87  // Switch LED on for a certain time to mark a switched Reed contact
88  if(getSamples()==1) {
89    digitalWrite(outputLED, HIGH);
90  } else {
91    digitalWrite(outputLED, LOW);
92  }
93
94  delay(100);
95}
Note: See TracBrowser for help on using the repository browser.