Changeset 4aaeb66 for de.wigbels.avr


Ignore:
Timestamp:
05/17/2009 10:25:10 PM (16 years ago)
Author:
njw <njw@…>
Branches:
master
Children:
71bba07
Parents:
78394ea
Message:

debouncing; more concrete testing...

File:
1 edited

Legend:

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

    r78394ea r4aaeb66  
    2424#include <pins_butterfly.h>
    2525
    26 int inputPin = PBPIN4;
     26int inputReed = PBPIN4;
     27int outputLED = PBPIN6;
     28
    2729int value = 0;
     30int debounce = 0;
    2831
    2932
    3033void setup() {
    3134  Serial.begin(9600);
    32   pinMode(inputPin, INPUT);
     35  pinMode(inputReed, INPUT);
     36  pinMode(outputLED, OUTPUT);
    3337}
    3438
    35 void getSamples(){
     39int getSamples(){
    3640  Serial.print("1");
    3741  Serial.print("\t");
     
    3943  Serial.println(); 
    4044
    41   value = digitalRead(inputPin);
    42   if (value == HIGH) {
    43     Serial.println("HIGH");
     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    }
    4458  }
    45   else {
    46     Serial.println("LOW");
    47   } 
    4859}
    4960
    5061void loop() { 
    5162  TempSense.overSample = true;
    52   getSamples();
    53   delay(400);
     63  if(getSamples()==1) {
     64    digitalWrite(outputLED, HIGH);
     65  } else {
     66    digitalWrite(outputLED, LOW);
     67  }
     68
     69  delay(100);
    5470}
Note: See TracChangeset for help on using the changeset viewer.