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 User0982u34 ( 5 years ago )
#include <Keyboard.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(8,7); // (ce,cs)
RF24Network network(radio);
const uint16_t this_node = 00;
const uint16_t other_node = 03;
unsigned int laser_state=0;
const unsigned long my_interval = 500;
unsigned long last_sent;
unsigned int income=0;
void setup(void)
{
Serial.begin(115200);
pinMode(9,INPUT_PULLUP);
SPI.begin();
radio.begin();
network.begin(90,this_node);
pinMode(4,OUTPUT);
digitalWrite(4,LOW);
}
void loop(void){
digitalWrite(4,LOW);
network.update();
if ( network.available() ) {
RF24NetworkHeader header;
network.read(header,&income,sizeof(income));
if(income==10){
Serial.println("f1");
Keyboard.press(KEY_F1);
income=0;
}
if(income==11){
Serial.println("f2");
Keyboard.press(KEY_F2);
income=0;
}
if(income==12){
Serial.println("ctrl");
Keyboard.press(KEY_LEFT_CTRL);
income=0;
}
if(income==13){
Serial.println("shift");
Keyboard.press(KEY_LEFT_SHIFT);
income=0;
}
Keyboard.releaseAll();
}
unsigned long now = millis();
if ( now - last_sent >= my_interval )
{
// Serial.print("pin ");
// Serial.println(digitalRead(9));
last_sent = now;
laser_state = digitalRead(9);
RF24NetworkHeader header(other_node);
bool ok = network.write(header,&laser_state,sizeof(laser_state));
}
}
Revise this Paste