hi every one
i made a wireless keyboard with NRF
wich have 4 keys F1, F2, left shift and left control
program and arduino works perfectly
but
the problem is , i cant hold bottoms
i mean when i hold bottom it hit rapidly
but what i want is to hold the bottom ( connect ) and when i release the bottom ( disconnect)
the bottom just as a real key board
i beg to help me
i add reciever and transfer codes and schematics of boards
please help me
its like cancer for me
Processing: wireless keyboard.rar...
Receiver_e5.ino (1.5 KB)
Transfer_e5.ino (1.6 KB)
Reciver code
#include <Keyboard.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(7,8); // (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));
}
}
and for Transfer
#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));
}
}
}