MBcreates
Published © GPL3+

Laser Activated NERF

I designed and built a laser-activated NERF system.

IntermediateShowcase (no instructions)5 hours5,255
Laser Activated NERF

Things used in this project

Story

Read more

Custom parts and enclosures

attachment

lasser body lit

lasser_body_uOSwsZTin5.STL

receiver_holder_YwTTLpbavy.STL

transmitter_holder_2k8wCYYoeK.STL

trigger clamp / servo holder

Schematics

transmitter_sketch_bb_cDD5wyBuer.jpg

laser_bb_W03Ak5opBG.jpg

receiver_sketch_bb_CKrnc4ARHV.jpg

Code

receiver.ino

Arduino
/*
 credits: Parts of this sketch are from this two tutorials
 https://www.youtube.com/watch?v=7rcVeFFHcFM&t=369s
 https://www.youtube.com/watch?v=4fN1aJMH9mM&t=125s
 
*/

#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

transmitter.ino

Arduino
/*
 credits: Parts of this sketch are from this two tutorials
 https://www.youtube.com/watch?v=7rcVeFFHcFM&t=369s
 https://www.youtube.com/watch?v=4fN1aJMH9mM&t=125s
 
*/

#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

Credits

MBcreates

MBcreates

2 projects • 2 followers

Comments