Hi all!

I have wired a button to the INT0 external interrupt so that every time 
said button is pressed the red led should be toggled. So press button once 
red led is on pres it again red led is off.

Oh and I am using a mica2dot.

I have coded it in the following way

In the header file:

TOSH_ALIAS_PIN(BUTTON, INT0)

In the code

TOSH_MAKE_BUTTON_INPUT();

To debounce the button I have defined a timer which will fire every 5 
Milliseconds. if several consecutive values (up to MAX_THRESHOLD) of 
READ_PIN are the same and indicate that the button was pressed I toggle 
the Led

event result_t BounceTimer.fired(){
 
    if ((TOSH_READ_BUTTON_PIN() == 1)) {
      result_counter++;
    } else if(TOSH_READ_TASTER_PIN() == 0) {
      result_counter = 0;
    }
 
    if(result_counter == MAX_THRESHOLD ) {
      result_counter = 0;
      if(statusOccupied == FALSE) {
        statusOccupied = TRUE;
        call Leds.redOn();
      } else if(statusOccupied == TRUE) {
        statusOccupied = FALSE;
        call Leds.redOff(); 
      }
    }
  }

This will not work as intended. If I press the button the red LED will 
toggle between on and off for several seconds before setttling in either 
the on or off state. This happens regardless of the value of MAX_THRESHOLD 
or the timer interval. (only the duration of the pulses is different)

So something is wrong but I do not get what it might be. Either it is my 
code or some other problem. The button is wired to the INT0 Pin (TP19) and 
the VCC Pin (TP6). My only other suggestion is that there are distortion 
on the wire connecting the mote and the mica2dot because it has roughly 
the same length as the antenna.

Any help is greatly appreciated.

Christian

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Tinyos-users mailing list
[email protected]
http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-users

Reply via email to