Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C++ by User87y234 ( 5 years ago )
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(8,7);
RF24Network network(radio);
const uint16_t this_node = 03;
const uint16_t other_node = 00;
unsigned int laser_state=0;
const unsigned long interval = 5;
unsigned long last_sent;
unsigned int b1=1;
unsigned int b2=1;
unsigned int b3=1;
unsigned int b4=1;
unsigned int d1=10;
unsigned int d2=11;
unsigned int d3=12;
unsigned int d4=13;
//TR1
int btn1 = 3;
int btn2 = 4;
int btn3 = 5;
int btn4 = 6;
void setup(void)
{
// Serial.begin(9600);
pinMode(btn1,INPUT_PULLUP);
pinMode(btn2,INPUT_PULLUP);
pinMode(btn3,INPUT_PULLUP);
pinMode(btn4,INPUT_PULLUP);
SPI.begin();
radio.begin();
network.begin(90,this_node);
}
void loop(void){
network.update();
unsigned long now = millis();
if ( now - last_sent >= interval )
{
last_sent = now;
b1 = digitalRead(btn1);
b2 = digitalRead(btn2);
b3 = digitalRead(btn3);
b4 = digitalRead(btn4);
if(b1==0){
// Serial.println("F1");
RF24NetworkHeader header(other_node);
bool ok = network.write(header,&d1,sizeof(d1));
}
if(b2==0){
// Serial.println("F2");
RF24NetworkHeader header(other_node);
bool ok = network.write(header,&d2,sizeof(d2));
}
if(b3==0){
// Serial.println("Ctrl");
RF24NetworkHeader header(other_node);
bool ok = network.write(header,&d3,sizeof(d3));
}
if(b4==0){
// Serial.println("Shift");
RF24NetworkHeader header(other_node);
bool ok = network.write(header,&d4,sizeof(d4));
}
}
}
Revise this Paste