osd-contiki/examples/osd/arduino-merkurboard/sketch.pde
2016-03-03 10:32:38 +01:00

46 lines
1.1 KiB
Plaintext

/*
* Sample arduino sketch using contiki features.
* We turn the LED off
* We allow read the moisture sensor
* Unfortunately sleeping for long times in loop() isn't currently
* possible, something turns off the CPU (including PWM outputs) if a
* Proto-Thread is taking too long. We need to find out how to sleep in
* a Contiki-compatible way.
* Note that for a normal arduino sketch you won't have to include any
* of the contiki-specific files here, the sketch should just work.
*/
extern "C" {
#include "rest-engine.h"
#include "net/netstack.h"
extern volatile uint8_t mcusleepcycle; // default 16
extern resource_t res_leds, res_battery, res_cputemp;
uint8_t door_pin = 3;
uint8_t door_status = 0;
#define LED_PIN 4
}
void setup (void)
{
// switch off the led
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
// init coap resourcen
rest_init_engine ();
rest_activate_resource (&res_leds, "s/leds");
rest_activate_resource (&res_battery, "s/battery");
rest_activate_resource (&res_cputemp, "s/cputemp");
// NETSTACK_MAC.off(1);
}
void loop (void)
{
mcusleepcycle=0;
mcusleepcycle=16;
}