Upgraded lamp zapper Build log

Want to show off your own project? Want to keep a build log of it? Post it here!
Post Reply
ToxyRocker
Posts: 5
Joined: Tue May 07, 2019 5:36 pm
Been thanked: 1 time

Upgraded lamp zapper Build log

Post by ToxyRocker » Wed May 15, 2019 5:53 pm

So when i found the video of the Lamp Zapper i wanted one. And only way to get it was to build one myself.

I have zero experience with arduino. So i spent an evening researching what i would need to build a better Lamp Zapper.
I looked for parts. And i found parts. Lots of cool stuff.

First i wanted the on/off switch to be triggered as you pulled the trigger and then turn off again to save battery as much as possible.
I also wanted the gun sound from shooting the ducks in Duck Hunt. So i had to look up how to fit that inside the zapper.
While searching i also found a haptic motor and controller witch would be nice to have.
Well, i ordered it all. I'm just waiting on the Adafruit Audio FX Mini Sound Board. After that i have all i need.
Image

Tonight i've been wiring everything up to be ready to be programed.
Image

The problem is that i have almost zero knowledge on how to program this.
When writing this i have manage to install everything and made the led on the board to blink.

So if anyone know any good beginners guide on how to program the arduino it would be appreciated.

User avatar
wermy
Site Admin
Posts: 1345
Joined: Tue May 03, 2016 8:51 pm
Has thanked: 618 times
Been thanked: 1319 times
Contact:

Re: Upgraded lamp zapper Build log

Post by wermy » Wed May 22, 2019 8:17 pm

ToxyRocker wrote:
Wed May 15, 2019 5:53 pm
So when i found the video of the Lamp Zapper i wanted one. And only way to get it was to build one myself.

I have zero experience with arduino. So i spent an evening researching what i would need to build a better Lamp Zapper.
I looked for parts. And i found parts. Lots of cool stuff.

First i wanted the on/off switch to be triggered as you pulled the trigger and then turn off again to save battery as much as possible.
I also wanted the gun sound from shooting the ducks in Duck Hunt. So i had to look up how to fit that inside the zapper.
While searching i also found a haptic motor and controller witch would be nice to have.
Well, i ordered it all. I'm just waiting on the Adafruit Audio FX Mini Sound Board. After that i have all i need.
Image

Tonight i've been wiring everything up to be ready to be programed.
Image

The problem is that i have almost zero knowledge on how to program this.
When writing this i have manage to install everything and made the led on the board to blink.

So if anyone know any good beginners guide on how to program the arduino it would be appreciated.
Awesome! Looking forward to seeing how it turns out; I've been meaning to upgrade mine with auto on/off functionality ever since I used that technique in another project like a year and a half ago. 😁
ImageImageImageImage

ToxyRocker
Posts: 5
Joined: Tue May 07, 2019 5:36 pm
Been thanked: 1 time

Re: Upgraded lamp zapper Build log

Post by ToxyRocker » Sat May 25, 2019 1:21 pm

Been sitting here for a few hours trying to understand how i2c works and how to write it in the code. No luck.
I keep getting these errors:
error: 'TwoWire' has not been declared
error: 'Serial' was not declared in this scope

I have no clue what they mean and why i get them. So i need to google around some more.

But there is some good news. I got the sound to work at least.

I'm gonna continue another day.

ToxyRocker
Posts: 5
Joined: Tue May 07, 2019 5:36 pm
Been thanked: 1 time

Re: Upgraded lamp zapper Build log

Post by ToxyRocker » Sun Feb 16, 2020 3:08 pm

Long time no see.
I never got it to work with the adafruit trinket. I didn't know why so I gave up.
Yesterday I tried again and found out that the trinket didn't have hardware serial. That's why nothing worked.

I got an Arduino micro instead and wow. Now the example sketches actually work so I can learn something.

Played with it this weekend and the only thing I have left is to figure out how to program the haptic motors to do one effect when I pull the trigger and not loop that effect as long as it has power.

Here's a short clip:

ToxyRocker
Posts: 5
Joined: Tue May 07, 2019 5:36 pm
Been thanked: 1 time

Re: Upgraded lamp zapper Build log

Post by ToxyRocker » Thu Feb 20, 2020 3:03 pm

Ok so i have come up with a way that works and does what i want.
Here's what i made so far:

Code: Select all

// Constants won't change. They're used here to set pin numbers:
const int irPin = 3;          // The number of the ir pin
const int soundPin =  4;      // The number of the sound trigger pin
const int motorPin =  5;      // The number of the motor trigger pin
const int powerPin =  2;      // The number of the power pin / trigger

void setup()
{
     pinMode(soundPin, OUTPUT);     // Initialize the Sound pin as an output
     pinMode(motorPin, OUTPUT);     // Initialize the Motor pin as an output
     pinMode(buttonPin, INPUT);     // Initialize the pushbutton pin as an input
     pinMode(powerPin, OUTPUT);     // Initialize the power pin as an output
     digitalWrite(powerPin, HIGH);  // Turns on power loop
     digitalWrite(soundPin, LOW);   // Turn off Sound trigger
}

void loop()
{
     digitalWrite(soundPin, HIGH);        // Triggers Sound to play
     delay(100);                          // Wait for the soundboard to register a signal
     digitalWrite(soundPin, LOW);         // Turn off Sound trigger
     delay(100);                          // Delays the Motor for timing with the sound
     digitalWrite(motorPin, HIGH);        // Turn Motor on
     delay(1000);                         // Runs the motor for 1 second
     digitalWrite(motorPin, LOW);         // Turn Motor off
     delay(1500);                         // Wait for the sound to finnish playing
     digitalWrite(powerPin, LOW);         // Turns off power loop
}
Now i need to figure out how the ir thing work.
This is the code for the zapper that wermy provided.

Code: Select all

#include <IRremote.h>
#include <Bounce2.h>

#define triggerPin 2

IRsend irsend;
Bounce trigger = Bounce(triggerPin, 10);

void setup() {
  pinMode(triggerPin, INPUT_PULLUP);
}

void loop() {
  trigger.update();
  if (trigger.fallingEdge()) {
    digitalWrite(13, HIGH);   
    delay(100);               
    digitalWrite(13, LOW);
    irsend.sendRC5('Z', 12);
    delay(20);
    irsend.sendRC5('P',12);
  }
}
From what i have learnd so far i have no clue how this works.
I have conected it exaktly as in the video but i get no response when i try it out. I used the same pins and made sure they had the same functions as the ones wermy used.
Am i right that i should see the ir diod flash when lookong through a camera?

If i look at the code i see "#define triggerPin 2" I have my trigger on pin 2 as well.
Then i see "bounce" witch i dont know what it is at the moment. It seems to refer to pin 10 witch wasn't mensiond in the video.
Then i see"digitalWrite(13, HIGH);" Pin 13 is the built in led on my Arduino Micro. I guess that this is intended to show something being sent on the ir diod with visual light on the built in led.
Lastly i see " irsend.sendRC5('Z', 12);" witch seems to refer to pin 12 witch also wasn't mensiond in the video.

Could someone help me understand this code?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest