source: de.wigbels.avr/sketchbook/hothotheat/hothotheat.pde@ 4aaeb66

Last change on this file since 4aaeb66 was 4aaeb66, checked in by njw <njw@…>, 16 years ago

debouncing; more concrete testing...

  • Property mode set to 100644
File size: 1.4 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
26int inputReed = PBPIN4;
27int outputLED = PBPIN6;
28
29int value = 0;
30int debounce = 0;
31
32
33void setup() {
34 Serial.begin(9600);
35 pinMode(inputReed, INPUT);
36 pinMode(outputLED, OUTPUT);
37}
38
39int getSamples(){
40 Serial.print("1");
41 Serial.print("\t");
42 Serial.print(TempSense.getTemp(CELSIUS));
43 Serial.println();
44
45 // switchtime of reed is 18 ms including debouncing...
46 value = digitalRead(inputReed);
47 delay(20);
48 debounce = digitalRead(inputReed);
49 if (value==debounce) {
50 if (value == HIGH) {
51 Serial.println("HIGH");
52 return 1;
53 }
54 else {
55 Serial.println("LOW");
56 return 0;
57 }
58 }
59}
60
61void loop() {
62 TempSense.overSample = true;
63 if(getSamples()==1) {
64 digitalWrite(outputLED, HIGH);
65 } else {
66 digitalWrite(outputLED, LOW);
67 }
68
69 delay(100);
70}
Note: See TracBrowser for help on using the repository browser.