osd-contiki/examples/osd/arduino-ledstrip/sketch.pde

73 lines
1.7 KiB
Plaintext
Raw Normal View History

2016-01-22 15:41:55 +01:00
/*
* 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.
*/
2016-01-23 17:49:51 +01:00
#include "RGBdriver.h"
2016-01-24 16:04:37 +01:00
#define CLK 3//pins definitions for the driver
#define DIO 14
2016-01-23 17:49:51 +01:00
RGBdriver Driver(CLK,DIO);
2016-01-22 15:41:55 +01:00
extern "C" {
#include "rest-engine.h"
2016-01-23 17:49:51 +01:00
#include "net/netstack.h"
2016-01-22 15:41:55 +01:00
2016-01-23 17:49:51 +01:00
extern volatile uint8_t mcusleepcycle; // default 16
2016-01-22 15:41:55 +01:00
extern resource_t res_door, res_battery;
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_door, "s/door");
rest_activate_resource (&res_battery, "s/battery");
2016-01-23 17:49:51 +01:00
NETSTACK_MAC.off(1);
2016-01-22 15:41:55 +01:00
}
void loop (void)
{
2016-01-23 17:49:51 +01:00
static int a=1;
mcusleepcycle=0;
2016-01-22 15:41:55 +01:00
2016-01-23 17:49:51 +01:00
switch(a) {
case 1: printf("a ist eins\n");
Driver.begin(); // begin
Driver.SetColor(255, 0, 0); //Red. first node data
Driver.end();
a++;
break;
case 2: printf("a ist zwei\n");
Driver.begin(); // begin
Driver.SetColor(0, 255, 0); //Green. first node data
Driver.end();
a++;
break;
case 3: printf("a ist drei\n");
Driver.begin(); // begin
Driver.SetColor(0, 0, 255);//Blue. first node data
Driver.end();
a=1;
break;
default: printf("a ist irgendwas\n"); break;
}
mcusleepcycle=16;
2016-01-22 15:41:55 +01:00
}