Changeset 86f2c9a
- Timestamp:
- 05/20/2009 06:50:07 PM (16 years ago)
- Branches:
- master
- Children:
- 789d162
- Parents:
- b51b715
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
de.wigbels.avr/sketchbook/hothotheat/hothotheat.pde
rb51b715 r86f2c9a 17 17 * 18 18 * Format: <# of Sensor> <data> 19 * Example: 1; Temperature in Celsius 20 * tbd. 19 * Example: 1 23.4 20 * 2 HIGH 21 * 3 14 21 22 */ 22 23 … … 29 30 30 31 int inputReed = PBPIN4; 31 int outputLED = PBPIN 3;32 int outputLED = PBPIN7; 32 33 33 34 int value = 0; 34 35 int debounce = 0; 36 int slewRate = 0; 37 int everySecond = 0; 35 38 36 long gasReeds = 0; 39 unsigned long gasReeds = 0; 40 int temp = 0; 41 37 42 38 43 void setup() { 39 LCD.prints_f( PSTR("HOTHOTHEAT"));40 delay( 2500);44 LCD.prints_f( PSTR( "HOTHOTHEAT" ) ); 45 delay( 2500 ); 41 46 42 47 // Set up the RTC timer to call the secTick() function every second. 43 48 RTCTimer.init( secTick ); 44 49 45 Serial.begin( 9600);50 Serial.begin( 9600 ); 46 51 47 52 TempSense.overSample = true; 48 53 49 pinMode(inputReed, INPUT); 50 pinMode(outputLED, OUTPUT); 54 pinMode( inputReed, INPUT ); 55 pinMode( outputLED, OUTPUT ); 56 57 digitalWrite( outputLED, HIGH ); 51 58 } 59 52 60 53 61 void secTick() 54 62 { 55 63 LCD.print( gasReeds ); 56 LCD.println( " tGR" ); 64 LCD.print( " G " ); 65 LCD.print( temp ); 66 LCD.println( " C" ); 67 everySecond=1; 57 68 } 58 69 70 59 71 int getSamples() { 60 // Temperature = Sensor 161 Serial.print("1");62 Serial.print("\t");63 Serial.println(TempSense.getTemp(CELSIUS));64 72 73 temp = TempSense.getTemp( CELSIUS ); 74 65 75 // switchtime of reed is 18 ms including debouncing... 66 value = digitalRead( inputReed);67 delay( 20);68 debounce = digitalRead( inputReed);76 value = digitalRead( inputReed ); 77 delay( 20 ); 78 debounce = digitalRead( inputReed ); 69 79 70 80 // 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++; 81 if ( value==debounce ) { 82 if ( value == HIGH ) { 83 slewRate=1; 77 84 return 1; 78 85 } 79 86 else { 80 Serial.println("LOW"); 87 if( slewRate==1 ) { 88 slewRate=0; 89 gasReeds++; 90 } 81 91 return 0; 82 92 } … … 84 94 } 85 95 96 86 97 void loop() { 87 // Switch LED on for a certain time to mark a switched Reed contact88 if( getSamples()==1) {89 digitalWrite( outputLED, HIGH);98 // LED marks Butterfly working; dark to mark a reed contact 99 if( getSamples()==1 ) { 100 digitalWrite( outputLED, LOW ); 90 101 } else { 91 digitalWrite( outputLED, LOW);102 digitalWrite( outputLED, HIGH ); 92 103 } 93 104 94 delay(100); 105 if ( everySecond==1 ) { 106 everySecond = 0; 107 108 // Temperature 109 Serial.print( "1" ); 110 Serial.print( "\t" ); 111 Serial.println( temp ); 112 113 // Reed HIGH or Low 114 Serial.print( "2" ); 115 Serial.print( "\t" ); 116 if( slewRate==1 ) { 117 Serial.println( "HIGH" ); 118 } else { 119 Serial.println( "LOW" ); 120 } 121 122 // Total of Gas Reeds 123 Serial.print( "3" ); 124 Serial.print( "\t" ); 125 Serial.println( gasReeds ); 126 } 127 128 delay(50); 95 129 }
Note:
See TracChangeset
for help on using the changeset viewer.