719de36b1bc14002f65082a12f2a879dc6200c9e
[wsn-p.git] / tutorial / ledbuttontest / ledbuttontest.c
1 #include <contiki.h>
2 #include <leds.h>
3 //#include <stdio.h>
4 #include <dev/button-sensor.h>
5
6 PROCESS(ledbuttontest, "LED button test");
7 AUTOSTART_PROCESSES(&ledbuttontest);
8
9 PROCESS_THREAD(ledbuttontest, ev, data) {
10 PROCESS_BEGIN();
11
12 leds_init();
13 leds_off(LEDS_ALL);
14
15 SENSORS_ACTIVATE(button_sensor);
16
17 static char i;
18 static struct etimer timer;
19 for(i = 0; 1; i++) {
20 PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
21
22 // debounce for 250 ms
23 etimer_set(&timer, CLOCK_SECOND * 0.25);
24 PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
25
26 if((i % 2)) {
27 leds_toggle(LEDS_GREEN);
28 }
29 leds_toggle(LEDS_YELLOW);
30 //printf("toggled\n");
31 }
32
33 PROCESS_END();
34 }
This page took 0.046554 seconds and 3 git commands to generate.