Changeset 789d162 for de.wigbels.avr/sketchbook/hothotheat
- Timestamp:
- 05/22/2009 10:07:45 PM (16 years ago)
- Branches:
- master
- Children:
- 5fb6ac6
- Parents:
- 86f2c9a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
de.wigbels.avr/sketchbook/hothotheat/hothotheat.pde
r86f2c9a r789d162 17 17 * 18 18 * Format: <# of Sensor> <data> 19 * Example: 1 23.4 20 * 2 HIGH 21 * 3 14 19 * Example: 1 23.4 -- Temperature 20 * 2 HIGH -- Reed count 21 * 3 14 -- Total of Reed counts since start of programm 22 22 */ 23 23 … … 34 34 int value = 0; 35 35 int debounce = 0; 36 int slewRate = 0;37 int everySecond = 0;36 int slewRate = LOW; 37 int everySecond = false; 38 38 39 39 unsigned long gasReeds = 0; … … 42 42 43 43 void setup() { 44 // Identify butterfly running program... 44 45 LCD.prints_f( PSTR( "HOTHOTHEAT" ) ); 45 46 delay( 2500 ); … … 56 57 57 58 digitalWrite( outputLED, HIGH ); 59 temp = TempSense.getTemp( CELSIUS ); 58 60 } 59 61 … … 65 67 LCD.print( temp ); 66 68 LCD.println( " C" ); 67 everySecond= 1;69 everySecond=true; 68 70 } 69 71 70 72 71 73 int getSamples() { 72 74 // Sensor 1 - Temperature 73 75 temp = TempSense.getTemp( CELSIUS ); 74 76 … … 78 80 debounce = digitalRead( inputReed ); 79 81 80 // Reedcontact = Sensor 2 82 // Sensor 2 - Reedcontact 83 // ...we are just interested in falling levels 84 // __|----|count_here__|----|_count_here__ 81 85 if ( value==debounce ) { 82 if ( value ==HIGH ) {83 slewRate= 1;84 return 1;86 if ( value==HIGH ) { 87 slewRate=HIGH; 88 return HIGH; 85 89 } 86 90 else { 87 if( slewRate== 1) {88 slewRate= 0;91 if( slewRate==HIGH ) { 92 slewRate=LOW; 89 93 gasReeds++; 90 94 } 91 return 0;95 return LOW; 92 96 } 93 97 } … … 97 101 void loop() { 98 102 // LED marks Butterfly working; dark to mark a reed contact 99 if( getSamples()== 1) {103 if( getSamples()==HIGH ) { 100 104 digitalWrite( outputLED, LOW ); 101 105 } else { … … 103 107 } 104 108 105 if ( everySecond==1 ) { 106 everySecond = 0; 109 // Output of 110 if ( everySecond==true ) { 111 everySecond = false; 107 112 108 113 // Temperature … … 126 131 } 127 132 128 delay( 50);133 delay(30); 129 134 }
Note:
See TracChangeset
for help on using the changeset viewer.