Hi!
I've got these fantastic Nerf Laser Ops. But my kids are too fast, I always loose.
I'm trying to simulate the signal. I suspect the signal is being transmitted with IR light. That's why I wrote this program and I also receive a signal.
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
/*
* IRremote: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
int RECV_PIN = 11; // Signaleingang ist PIN 11
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
// decode_results *results = (decode_results *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
else if (results->decode_type == PANASONIC) {
Serial.print("Decoded PANASONIC: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}
else if (results->decode_type == SAMSUNG) {
Serial.print("Decoded SAMSUNG: ");
}
int val1 = results->value;
Serial.print(val1, HEX);
Serial.print(" (");
int valbits = results->bits;
Serial.print(valbits, DEC);
Serial.println(" bits)");
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
int valen = results->rawbuf[i]*USECPERTICK;
Serial.print(valen, DEC);
}
else {
int negvalen =-(int)results->rawbuf[i]*USECPERTICK;
Serial.print(negvalen, DEC);
}
Serial.print(", ");
}
Serial.println("");
}
void loop() {
if (irrecv.decode(&results)) {
int hexen = results.value;
Serial.println(hexen, HEX);
dump(&results);
irrecv.resume(); // Receive the next value
}
}
I have fired the same signal over 100 times. It's fluctuating, but I think I'm quite good statistically. Now I have written another program, which sends the signal.
#include <IRremote.h> // IRremote Bibliothek nachladen
IRsend irsend;
// RAW Signal zum an/ausschalten des Fernsehers
//unsigned int powerOn[68] = {4500, 4450, 600, 1600, 600, 1650, 550, 1650, 600, 500, 600, 550, 550, 550, 600, 500, 600, 500, 600, 1650, 550, 1650, 600, 1650, 550, 550, 550, 550, 600, 500, 600, 500, 600, 550, 550, 550, 550, 1650, 600, 500, 600, 550, 550, 550, 550, 550, 600, 500, 600, 500, 600, 1600, 600, 550, 600, 1600, 600, 1650, 550, 1650, 600, 1650, 550, 1650, 600, 1650, 550};
// rot
//unsigned int powerOn[68] = {3000,1900,950,1900,950,1900,950,1900,950,1950,1950,1950,900,1950,950,1900,950,1950,900,2000,850,2000,950,1950,900,2000,900,1950,900,2000,950,1950,900};
// blau
unsigned int powerOn[68] = {2950,1950,850,2000,850,2000,850,2000,850,2000,1850,2050,850,2000,850,2000,850,2000,900,2000,1850,2000,850,2000,850,2000,850,2000,850,2000,850,2000,850};
//test
// unsigned int powerOn[68] = {700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100};
void setup()
{
Serial.begin(9600);
}
void loop() {
irsend.sendRaw(powerOn,68,38); //RAW Signal, laenge, frequenz meistens 38kHz
delay(1000);
}
The receiver program shows that the signal from the NERF is identical to the one I sent. But if I send the simulated signal to the NERF, then the NERF does not react. Nothing happens. I tried several IR-LED: 850nm, 880nm, 940nm, 950nm. The ARDUINO-receiver is the TSOP4838. But I don't know, which receiver is in the NERF. I've got a picture:
![]()
Here are two pictures of the transmitter and the receiver.
![]()
![]()
I'm not an ARDUINO-expert. Does anyone have an idea why the NERF does not receive or react to the signal?






