Ignore:
Timestamp:
05/22/2009 10:07:45 PM (16 years ago)
Author:
njw <njw@…>
Branches:
master
Children:
5fb6ac6
Parents:
86f2c9a
Message:

no chance to use the Interrupt-API with the Butterfly?!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • de.wigbels.avr/sketchbook/hothotheat/hothotheat.pde

    r86f2c9a r789d162  
    1717 *
    1818 * 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
    2222 */
    2323 
     
    3434int value = 0;
    3535int debounce = 0;
    36 int slewRate = 0;
    37 int everySecond = 0;
     36int slewRate = LOW;
     37int everySecond = false;
    3838
    3939unsigned long gasReeds = 0;
     
    4242
    4343void setup() {
     44  // Identify butterfly running program...
    4445  LCD.prints_f( PSTR( "HOTHOTHEAT" ) );
    4546  delay( 2500 );
     
    5657 
    5758  digitalWrite( outputLED, HIGH );
     59  temp = TempSense.getTemp( CELSIUS );
    5860}
    5961
     
    6567  LCD.print( temp );
    6668  LCD.println( " C" );
    67   everySecond=1;
     69  everySecond=true;
    6870}
    6971
    7072
    7173int getSamples() {
    72 
     74  // Sensor 1 - Temperature
    7375  temp = TempSense.getTemp( CELSIUS );
    7476 
     
    7880  debounce = digitalRead( inputReed );
    7981
    80   // Reedcontact = Sensor 2
     82  // Sensor 2 - Reedcontact
     83  // ...we are just interested in falling levels
     84  // __|----|count_here__|----|_count_here__
    8185  if ( value==debounce ) {   
    82     if ( value == HIGH ) {
    83       slewRate=1;
    84       return 1;
     86    if ( value==HIGH ) {
     87      slewRate=HIGH;
     88      return HIGH;
    8589    }
    8690    else {
    87       if( slewRate==1 ) {
    88         slewRate=0;
     91      if( slewRate==HIGH ) {
     92        slewRate=LOW;
    8993        gasReeds++;
    9094      }
    91       return 0;
     95      return LOW;
    9296    }
    9397  }
     
    97101void loop() { 
    98102  // LED marks Butterfly working; dark to mark a reed contact
    99   if( getSamples()==1 ) {
     103  if( getSamples()==HIGH ) {
    100104    digitalWrite( outputLED, LOW );
    101105  } else {
     
    103107  }
    104108
    105   if ( everySecond==1 ) {
    106     everySecond = 0;
     109  // Output of
     110  if ( everySecond==true ) {
     111    everySecond = false;
    107112
    108113    // Temperature
     
    126131  }
    127132   
    128   delay(50);
     133  delay(30);
    129134}
Note: See TracChangeset for help on using the changeset viewer.