Project coding help

I'm trying to create a laser trip wire that activates a servo when the laser is broken. I'm using NRF24L01+ boards to communicate from the transmitter box to the receiver box with the servo. I'm new programing can someone please help and point me in the right direction. I'm using two Arduino Nano Every.

TRANSMITTER

#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define LEDS 1
#define PIN 10


const int ldrPin = A0;  

Adafruit_NeoPixel strip = Adafruit_NeoPixel(LEDS, PIN ,NEO_GRB + NEO_KHZ800);


RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};



int ldrStatus;



void setup() {

  Serial.begin(9600);
  pinMode(12, OUTPUT);
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00001
  radio.openReadingPipe(1, addresses[0]); // 00002
  radio.setPALevel(RF24_PA_MAX);


  strip.begin();
  strip.show();  
  
}




void loop() {

 
  ldrStatus = analogRead(ldrPin);  


           delay(5);
    radio.stopListening();
   
    radio.write(&ldrStatus, sizeof(ldrStatus));

if(ldrStatus>940)
{
  strip.setPixelColor(0, 0, 255, 0); //RED
 strip.show();
}
     
else
{
  strip.setPixelColor(0, 255, 0, 0); //GREEN
 strip.show();  
}



  
}   // end of program

RECIEVER

#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>

#define LEDS 1
#define PIN 10

Adafruit_NeoPixel strip = Adafruit_NeoPixel(LEDS, PIN ,NEO_GRB + NEO_KHZ800);


RF24 radio(7, 8);
const byte addresses[][6] = {"00001", "00002"};
Servo servo1;



int ldrStatus;


void setup() {
  
  Serial.begin(9600);
  pinMode(button, INPUT);
  servo1.attach(5);
  radio.begin();
  radio.openWritingPipe(addresses[0]); 
  radio.openReadingPipe(1, addresses[1]); 
  radio.setPALevel(RF24_PA_MAX);

  pinMode(button,INPUT_PULLUP);


  strip.begin();
  strip.show(); 

  strip.setPixelColor(0, 0, 0, 0); 
  strip.show(); 
  
}
void loop() {


if(ldrStatus==0)
{
   strip.setPixelColor(0, 0, 0,  255); //BLUE
 strip.show();
}
 if(ldrStatus>0)
 {
   strip.setPixelColor(0,0,  255, 0); //RED
    strip.show(); 
 }

delay(5);
  radio.startListening();
  radio.read(&ldrStatus, sizeof(ldrStatus));

servo1.write(100);

  if((ldrStatus<940)&& (ldrStatus>10))
  {
      strip.setPixelColor(0, 255, 0, 0); //GREEN
 strip.show();  
       servo1.write(30);
    delay(100);
  }
  
}   // end of program

Welcome to the forum

What do you need help with ?
What do the sketches do when you run them ?
What should they do ?

the laser points to a LDR in the Transmitter Box. I want to send to the receiver box when the laser transmission is broken to activate a servo. I have uploaded the sketches and they do absolutely nothing lol just the LED turns a yellow color. I have added pictures of the set up. I'm using 2 18650 Batteries instead of the 9V. I have 5528 LDR, L7805 5V Voltage regulators. I tried using both the 3V Voltage regulators for the NRF24L01+ boards and just using the 3.3V pin. I also installed a 10uF Decoupling capacitor for the NRF24L01+ boards. I'm just wanting to make sure i have all this set up correctly.



This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.