thank you
Posts made by magkudjee
-
RE: nRF5 action!
Hi every one. I'm very new in mysensors (I use bad English)
in my sketch how to setup sleep,interrupt for 3 button (์NRF51822)
thank you#define MY_DEBUG #define MY_NODE_ID 4 //#define MY_RADIO_NRF24 #define MY_RADIO_NRF5_ESB #include <SPI.h> #include <MySensors.h> #define CHILD_ID_SW1 1 #define CHILD_ID_SW2 2 #define CHILD_ID_SW3 3 #define BUTTON1_PIN 3 #define BUTTON2_PIN 4 #define BUTTON3_PIN 5 boolean sw1State; boolean lastState1; boolean tripped1 = HIGH; boolean sw2State; boolean lastState2; boolean tripped2 = HIGH; boolean sw3State; boolean lastState3; boolean tripped3 = HIGH; MyMessage msg1(CHILD_ID_SW1, V_TRIPPED); MyMessage msg2(CHILD_ID_SW2, V_TRIPPED); MyMessage msg3(CHILD_ID_SW3, V_TRIPPED); void presentation() { sendSketchInfo("Push Button 1", "1.0"); present(CHILD_ID_SW1, S_DOOR); present(CHILD_ID_SW2, S_DOOR); present(CHILD_ID_SW3, S_DOOR); } void setup() { pinMode (BUTTON1_PIN,INPUT_PULLUP); pinMode (BUTTON2_PIN,INPUT_PULLUP); pinMode (BUTTON3_PIN,INPUT_PULLUP); } void loop() { sw1State = digitalRead(BUTTON1_PIN); if ( ( sw1State == LOW) && (lastState1 == HIGH) ) tripped1 = !tripped1; send(msg1.set(tripped1==HIGH ? "1" : "0")); lastState1 = sw1State; sw2State = digitalRead(BUTTON2_PIN); if ( ( sw2State == LOW) && (lastState2 == HIGH) ) tripped2 = !tripped2; send(msg2.set(tripped2==HIGH ? "1" : "0")); lastState2 = sw2State; sw3State = digitalRead(BUTTON3_PIN); if ( ( sw3State == LOW) && (lastState3 == HIGH) ) tripped3 = !tripped3; send(msg3.set(tripped3==HIGH ? "1" : "0")); lastState3 = sw3State; //sleep(digitalPinToInterrupt(BUTTON1_PIN), CHANGE, 0); //sleep(INTERRUPT, CHANGE, 0); }