Using MySensors feature in a library



  • Hey guys,

    im using the mysensors 2 library and im trying to use the wait and sleep feature in my own library to seperate project features. I tried the following:

    MotionSensor.h:

    #ifndef MotionSensor_h
    #define MotionSensor_h
    
    	#include "../MySensors/core/MySensorsCore.h"
    	#include "SPI.h" 
    	#include "Arduino.h"
    .
    .
    .
    #endif
    

    MotionSensor.cpp:

    #include <MotionSensor.h>
    
    MotionSensor::MotionSensor(int pin,  int initTime)
    {
    	_pin = pin;
    	pinMode(_pin, INPUT);
    
    	for(int i = 0; i < initTime; i++){
    		wait(1000);
    	}
    }
    

    and in my main sketch im setting everything up:

    // MySensorStuff
    #define MY_DEBUG //Comment out in production mode
    #define MY_RADIO_NRF24 //use the NRF24L01+ module
    #include <SPI.h>
    #include <MySensors.h>
    
    #include <MotionSensor.h>
    MotionSensor motion(2, 2);
    
    void setup(){
    Serial.println("setup");
    }
    
    void presentation(){
     sendSketchInfo("TestSketch", "1.0");
    
    void loop(){
    Serial.println("loop");
    }
    

    The code will compile but on my Arduino Uno the Network will not setup. Hope you guys can help me out :+1:


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.