Wifi points over Arduino Nano


Used hardware:

  • Arduino NanoEthernet Shield Wiznet W5100
  • Nrf24l01 + PA + LNA
  • Pushbuttons
  • LED diodes
  • Buzzer
  • Description of functionality and use:

  • The system is designed for Airsoft / Paintball / Nerf Wars for Capture point game mode.
  • The system uses the Arduino Nano pair for the 2 points that players are fighting on, each of the boards being two diodes, two detectors, two wifi modules nRF24l01 + PA + LNA. In addition to these components, the buttons for each of the teams are also placed on the boards.
  • One button is for Team 1 (yellow team) and second for Team 2 (red team). In the event of a cast, they press their button to change the color of the point according to their team.
  • If one team occupies both points, the detector sounds at both points (the game ends or continues according to the organizer"s rules). This may mean, for example, only the end of the round or the addition of points. In real-time, both Arduina communicate with the nRF24l01 + PA + LNA modules. The response between the two Arduins is at 1-5ms.
  • Thanks to the nRF24l01 modules, it is possible to communicate with Arduin at huge distances of hundreds of meters in an uninterrupted environment (nRF24l01 offers over 120 channels for communication to 2.4Ghz.) With an external 5v / 3.3v source it is possible to communicate up to 1.1 kilometers.
  • Receiver

    // nRF24L01 prijimac
    #include <SPI.h> //arduino kniznica pre SPI zbernicu
    #include "RF24.h" //kniznica pre moduly
    int odezva = 3; //globalna premenna pre odosielany stav timu
    int prijem = 4; //globalna premenna pre citany stav timu
    const int buzzer = 2; //pin pre hlasic
    const int cervenytim = 5; //pin pre cerveny button
    const int zltytim = 6;  //pin pre zlty button
    const int cervenaled = 7;
    const int zltaled = 8;
    #define CE 4 //chip state pin
    #define CS 3 //chip select pin
    RF24 nRF(CE, CS); //nrf s volitelnymi pinmi CE a CS
    byte adresaPrijimac[] = "prijimac00"; //adresa prijimac
    byte adresaVysilac[] = "vysilac00"; //adresa vysielac
    void setup() {
      Serial.begin(9600); //Serial monitor na 9600 baud/s
      pinMode(buzzer, OUTPUT); //hlasic nastavit ako vystup
        pinMode(cervenaled, OUTPUT);
      pinMode(zltaled, OUTPUT);
      pinMode(cervenytim, INPUT_PULLUP); //tlacidla ako vstup na pullup rezistor
      pinMode(zltytim, INPUT_PULLUP); //tlacidla ako vstup na pullup rezistor
      nRF.begin(); //zapnut komunikaciu s nRF modulom
      nRF.setDataRate( RF24_250KBPS ); //najnizsia rychlost pre najvacsiu moznu vzidalenost
      nRF.setPALevel(RF24_PA_HIGH); //napajacie napatie na high moznost MAX potrebuje externy zdroj na 5v (3.3v pri napojeni napriamo)
      nRF.openWritingPipe(adresaPrijimac); //zapisujeme na prijimac na jeho adresu
      nRF.openReadingPipe(1, adresaVysilac); //citame na svojej adrese na kanale XX
      nRF.startListening();
    }
    
    void loop() {
     if(odezva == prijem){
              
      tone( buzzer, 900, 800);
     
      delay(1000);
          }else{
            noTone(buzzer);
             int vystupcerveny = digitalRead(cervenytim);
      int vystupzlty = digitalRead(zltytim);
      if(vystupcerveny==LOW){
        odezva = 1;
        digitalWrite(cervenaled, HIGH);
        digitalWrite(zltaled, LOW);
        }else if(vystupzlty==LOW){
        odezva = 2;
         digitalWrite(cervenaled, LOW);
        digitalWrite(zltaled, HIGH);
        }
       
      if ( nRF.available()) {
        // čekání na příjem dat
        while (nRF.available()) {
          nRF.read( &prijem, sizeof(prijem) );
        }
        Serial.println("Prijata volba: ");
        Serial.println(prijem);
        Serial.println("Odozva: ");
        Serial.println(odezva);
        nRF.stopListening();
        nRF.write( &odezva, sizeof(odezva) );
        nRF.startListening();
      }
            }  
    
    }
    					 

    Transmitter

    // nRF24L01 vysielac
    #include <SPI.h>
    #include "RF24.h"
    #define CE 4
    #define CS 3
    RF24 nRF(CE, CS);
    int odezva = 8;
    int prijem = 12;
    const int buzzer = 2;
    const int cervenytim = 5;
    const int zltytim = 6;
    const int cervenaled = 7;
    const int zltaled = 8;
    byte adresaPrijimac[]= "prijimac00";
    byte adresaVysilac[]= "vysilac00";
    void setup() {
      Serial.begin(9600);
      pinMode(buzzer, OUTPUT);
      pinMode(cervenaled, OUTPUT);
      pinMode(zltaled, OUTPUT);
      pinMode(cervenytim, INPUT_PULLUP);
      pinMode(zltytim, INPUT_PULLUP);
      nRF.begin();
      nRF.setDataRate( RF24_250KBPS );
      nRF.setPALevel(RF24_PA_HIGH);
      nRF.openWritingPipe(adresaVysilac);
      nRF.openReadingPipe(1,adresaPrijimac);
      nRF.startListening();
    }
    
    void loop() {
     if(odezva == prijem){
              
      tone( buzzer, 900, 800);
     
      delay(1000);
          }else{
            noTone;
            int vystupcerveny = digitalRead(cervenytim);
      int vystupzlty = digitalRead(zltytim);
      if(vystupcerveny==LOW){
        odezva = 1;
        digitalWrite(cervenaled, HIGH);
        digitalWrite(zltaled, LOW);
        }else if(vystupzlty==LOW){
        odezva = 2;
        digitalWrite(cervenaled, LOW);
        digitalWrite(zltaled, HIGH);
        }
        
        nRF.stopListening();
         nRF.write( &odezva, sizeof(odezva) );
        nRF.startListening();
     while (nRF.available()) {
          nRF.read( &prijem, sizeof(prijem) );
        }
        Serial.println("Prijata volba: ");
        Serial.println(prijem);
        Serial.println("Odozva: ");
        Serial.println(odezva);
        delay(50);
            
            
            }
      
      
      }