Page 2 of 3

Re: Cylon Rifle with Lights and Sound

Posted: Wed Jul 25, 2018 7:47 am
by welshchris77
Pretty much finished, the two halves have been tapped together, greeblies glued on and electronics all successfully tested, yay!

Video link electronics test
https://www.dropbox.com/s/hr7rp15lb76rm ... 8.mp4?dl=0

ImageImage

Re: Cylon Rifle with Lights and Sound

Posted: Wed Jul 25, 2018 11:32 am
by Red Eye
Very nice tutorial!

Thank you for sharing.

Re: Cylon Rifle with Lights and Sound

Posted: Wed Jul 25, 2018 12:15 pm
by Cylon-Knight
EPIC BUILD!!!
:loveit:

Re: Cylon Rifle with Lights and Sound

Posted: Wed Jul 25, 2018 6:02 pm
by welshchris77
Cylon-Knight wrote:
Wed Jul 25, 2018 12:15 pm
EPIC BUILD!!!
:loveit:
Red Eye wrote:
Wed Jul 25, 2018 11:32 am
Very nice tutorial!

Thank you for sharing.
Your very welcome, thanks for the support.
If anyone is interested I can put up the wiring diagram and code needed to do this :wink:

Re: Cylon Rifle with Lights and Sound

Posted: Thu Jul 26, 2018 6:40 am
by Soda Can
:loveit: that is a very nice build, yes to the diagram and code please.
What will be next.
I would put two sound files on this, the first classic cylon blaster sound, the second for a laugh would have to be a pew pew sound file.

Re: Cylon Rifle with Lights and Sound

Posted: Fri Jul 27, 2018 2:35 pm
by Cylon-Knight
PEW PEW!

I love it. #sold ;)
:evillaugh:

Re: Cylon Rifle with Lights and Sound

Posted: Fri Jul 27, 2018 3:19 pm
by Soda Can
I thought it would be a good idea to make those lowly humans do our bidding, especially if everyone is going to be able to talk in character thanks to the roland VT3, this would sound a bit odd with a cylon doing the pew pew.
Although in saying that, that could be another good sound file, maybe :cylon:

Re: Cylon Rifle with Lights and Sound

Posted: Sat Jul 28, 2018 6:05 am
by welshchris77
Ok folks I have put together the wiring diagram, code and parts list :D

If you would like the files in a higher resolution email me here and I will send them to you welshchrisinireland@yahoo.co.uk
I can also send the sound file!


I am in no way a programmer so my code may be a little scrappy, some of it is adapted from a Stormtrooper E11 code used on a different project, there is a section in it for a rotary switch that is no longer being used, I tried to remove it but it seemed to affect the circuit so I just left it in, it doesn't affect the way the rifle operates so use the code as it is or feel free to tinker with it if you wish.
Also there is a slight pause with the sound on the first press of the trigger (no idea why), after that it works fine.

You might want to move the on/off switch to a different position, where I placed mine it was getting knocked off by my glove, I solved it by rewiring the switch in reverse so it gets knocked on rather than off, if that makes sense!

****Important!!!!!, Please be careful when wiring, if you look closely there are basically two power circuits 7.2v from the battery, this powers the led drivers and the Arduino, the rest is powered from the Arduino's 5v output, trigger switch, mp3 player, amplifier chip, dont mix these up or you may very well burn something out!

If anything goes wrong I take no responsibility!

Any questions feel free to ask :grin:

Image

Code:-


/*
Project "Cylon Rifle"
Version 1.0 : Light and Sound
*/
// Define Pin layout
const int PinTrigger = 2; // Trigger function
const int PinLED1 = 5;// Led closest to Trigger
const int PinLED2 = 6;
const int PinLED3 = 7;
const int PinLED4 = 8;
const int PinLED5 = 9;
const int PinLED6 = 10;
const int PinLED7 = 11; // Led at nozzle

// Define const for Firing modes
const int FireModeSingle = 1; // DigitalValue (0001)= Rotarypos 1 for Single fire mode
const int FireModeBurst = 9; // DigitalValue (1001)= Rotarypos 9 for Burst fire mode
const int BurstMode = 3; // Amout of sequence repeats on one trigger action
const int Hold_Delay = 50; // [msec] time the trigger must be pushed before activation
const int DelayTime = 50; // [msec] delay between LEDs
const int DelayTimeEnd = 200; // [msec] duration of LED at nozzle

// Variables
int TriggerState = 0; //Reads status of Trigger
int SwitchValue = 0; // Readout of Rotary switch
int SequenceRepeats = 1; // Amount of sequences per Trigger
int PreviousState = 0; // PreviousState of Trigger
unsigned long TimeTriggerPressed; // Time at which the trigger is pressed
boolean SequenceStart = false; // Allow Sequence to Start

void setup() {
// Setup pin modes
pinMode(PinTrigger, INPUT); //Trigger
pinMode(PinLED1, OUTPUT); // Pin Led1 (closest at trigger)
pinMode(PinLED2, OUTPUT);
pinMode(PinLED3, OUTPUT);
pinMode(PinLED4, OUTPUT);
pinMode(PinLED5, OUTPUT);
pinMode(PinLED6, OUTPUT);
pinMode(PinLED7, OUTPUT); // Pin Led7 (Led at nozzle)

digitalWrite(PinLED1,LOW); //Turn off led1
digitalWrite(PinLED2,LOW); //Turn off led2
digitalWrite(PinLED3,LOW); //Turn off led3
digitalWrite(PinLED4,LOW); //Turn off led4
digitalWrite(PinLED5,LOW); //Turn off led5
digitalWrite(PinLED6,LOW); //Turn off led6
digitalWrite(PinLED7,LOW); //Turn off led7

Serial.begin(9600); //Baudrate

Serial.write(0x7E);
Serial.write(0x03);
Serial.write(0xA7);
Serial.write(0x1d); // volume (hexadecimal conversion 1-31 --> 1f = max / 14 = medium)
Serial.write(0x7E);
}

void loop() {

TriggerState = digitalRead(PinTrigger); // read trigger status

// Check state Trigger
if (( TriggerState == HIGH) && (PreviousState == LOW)) { //Mark pressing moment
SequenceStart = true;
TimeTriggerPressed = millis();
}

if (( TriggerState == HIGH) && ( PreviousState == HIGH) && ( SequenceStart == true)) {
if (( millis() - TimeTriggerPressed) >= Hold_Delay) {
for(int x = 0;x<SequenceRepeats; x++) {
// play Led sequence
digitalWrite(PinLED1,HIGH);
delay(DelayTime);
digitalWrite(PinLED1,LOW);
digitalWrite(PinLED2,HIGH);
delay(DelayTime);
digitalWrite(PinLED2,LOW);
digitalWrite(PinLED3,HIGH);
delay(DelayTime);
digitalWrite(PinLED3,LOW);
digitalWrite(PinLED4,HIGH);
delay(DelayTime);
digitalWrite(PinLED4,LOW);
digitalWrite(PinLED5,HIGH);
delay(DelayTime);
digitalWrite(PinLED5,LOW);
digitalWrite(PinLED6,HIGH);
delay(DelayTime);
digitalWrite(PinLED6,LOW);
digitalWrite(PinLED7,HIGH);
delay(DelayTimeEnd);
digitalWrite(PinLED7,LOW);

Serial.write(0x7E);
Serial.write(0x04);
Serial.write(0xA0); // A0 for SD card
Serial.write(0x00);
Serial.write(0x01); // track number
Serial.write(0x7E);
}
SequenceStart = false;
}
}
PreviousState = TriggerState;
}










Parts list, most with links


1. Arduino Nano (the software I use with this clone is 'Arduino 1.0.6')

https://www.ebay.ie/itm/Nano-V3-0-Mini- ... nrcpbSjN7g

2. WT5001M02 28P U disk Audio Player Card Voice Module MP3 Sound For Arduino&WS

https://www.ebay.ie/itm/WT5001M02-28P-U ... SwzaJX4N5D

3. 2 Channels 3W Digital power PAM8403 Class D Audio Amplifier Board USB 5V
https://www.ebay.ie/itm/10PCS-2-Channel ... SwRQlXdzT6


4. EN-EL9 7.2V 1200mAh battery 2 + LCD display USB charger + USB cab J9P8 (these are cheap chinese ones but work fine for me!, the nikon ones are really expensive)
https://www.ebay.ie/itm/For-Nikon-EN-EL ... SwbKRbP6gu


5. Led Diver
https://www.ebay.ie/itm/New-3W-700mA-DC ... 2380834ee2

6.1w led smd White
https://www.ebay.ie/itm/50pcs-1W-LED-SM ... 2749.l2649


7.1w led smd Blue
https://www.ebay.ie/itm/10x-50x-1W-3W-5 ... Z20-jHtbQA


8. 4Ohm 3W Round Inside Magnet Loudspeaker for USB Bluetooth Speaker
https://www.ebay.ie/itm/2W-0-5W-8Ohm-4O ... ayxCv6WG1g


9. Micro on/off switch
https://www.ebay.ie/itm/20pcs-lot-SS12F ... Swf-xZnsC6


10. Red Mini Lockless Momentary ON/OFF Push button Switch
https://www.ebay.ie/itm/10pcs-Red-Mini- ... SwxKtYBw2U


11. 1/8w 1kohm resistor
https://www.ebay.ie/itm/1000PCS-High-Pr ... SwuHJbD4fw


12. 1/4w 10kohm resistor
https://www.ebay.ie/itm/1Set-100pcs-1-4 ... SwqYBWmLyY


13. Solder
https://www.ebay.ie/itm/100g-0-8mm-60-4 ... 4b199ca121


14. Heat shrink tubing (sizes between 1.5mm to 3mm)


15. JST XH 2.5mm connectors and crimping tool (not necessary for the circuit but handy for maintenance)
https://www.ebay.ie/itm/50SETS-of-JST-X ... GK2XOKQVvw
https://www.ebay.ie/itm/Mini-Mirco-JST- ... SwevlaJ6h3


16. 22 gauge Wire (red and black mostly, I used different colours for the Led control cables but you could just use red or black either)
https://www.ebay.ie/itm/Equipment-Wire- ... xydlFSyOxp


17. A good quality soldering station (you will need it for fine soldering, below is the one I use but its up to you what one you choose)
https://www.ebay.ie/itm/AOYUE-INT9378-6 ... SwWxNatUeV


18. Solder sucker
https://www.ebay.ie/itm/190mm-Soldering ... Sw8FBbF6Op


19. Micro SD card (sandisk are good)


20. precision side cutters, wire stippers and mini needle noose pliers


21. Helping hands (you will use these a lot!)
Probably some other stuff I haven't thought of too, I will add if I think of anything else

Re: Cylon Rifle with Lights and Sound

Posted: Tue Sep 11, 2018 11:07 pm
by FLIGHTLDR SERPENTINE
Geez. Alot of work there!

Re: Cylon Rifle with Lights and Sound

Posted: Wed Sep 12, 2018 3:42 am
by Soda Can
Just a thought, can the leds and driver boards be swapped out with neo pixels?

Re: Cylon Rifle with Lights and Sound

Posted: Wed Sep 12, 2018 4:50 am
by welshchris77
Soda Can wrote:Just a thought, can the leds and driver boards be swapped out with neo pixels?
I have never used neo pixels before but I guess you could incorporate them into the circuit, I believe neopixel run off 5v though you would have to tap into the output from the Arduino rather that the 7.4v batteries output I used for the LED's in this projectImage

Sent from my SM-A310F using Tapatalk


Re: Cylon Rifle with Lights and Sound

Posted: Wed Sep 19, 2018 9:30 am
by MackUK
:frack: This is an awesome build. way beyond my electronics capabilities. But showing what it can do... amazing!!

I love this. For me, when I get my 3D printed one finished and sanded and stuck together, it'll be a flashing light at the front... that's it.


Well done on an epic build!

Mack

Re: Cylon Rifle with Lights and Sound

Posted: Wed Sep 19, 2018 10:49 am
by welshchris77
Thanks Mack, the circuit is not as complex as it looks believe it or not, if you have any kind of basic soldering skills you could do itImage.
The fabricating of the bits to hold it all in was the trickiest bits to do.
MackUK wrote::frack: This is an awesome build. way beyond my electronics capabilities. But showing what it can do... amazing!!

I love this. For me, when I get my 3D printed one finished and sanded and stuck together, it'll be a flashing light at the front... that's it.


Well done on an epic build!

Mack
Sent from my SM-A310F using Tapatalk



Re: Cylon Rifle with Lights and Sound

Posted: Sat Sep 22, 2018 2:52 pm
by MackUK
I'm good with soldering, but..

I don't know how to program the Arduino boards. I'm also not good with the schematics of the circuits between the boards. Also no good in making sure the initial circuit on the breadboard would work (I don't even know how to use one!) :erk:


I'm sticking with the flash light approach. Seems well within my capabilities.

Re: Cylon Rifle with Lights and Sound

Posted: Sat Sep 22, 2018 3:19 pm
by Soda Can
MackUK wrote:
Sat Sep 22, 2018 2:52 pm
I'm good with soldering, but..

I don't know how to program the Arduino boards. I'm also not good with the schematics of the circuits between the boards. Also no good in making sure the initial circuit on the breadboard would work (I don't even know how to use one!) :erk:


I'm sticking with the flash light approach. Seems well within my capabilities.
I'm in exactly the same position as you MackUK, i have never used the arduino boards or programmed anything up as yet.
But we have to start somewhere, I'm working on a bb8 and bb9 unit with some slow but will be positive results.
It's just a matter of reading through what everyone else is doing, I've just got a cr10s 3d printer recently also, it will be great for this hobby and fun to learn along the way.
Just keep asking questions, there's no harm in doing that, that's how we all learn and help each other out.
That is also why I'm a part of this and other forums, great people offering help to us newbies along the way, then we can pass the same onto others once we've grasped the basics.
Keep up the great work centurian, and we'lllook forward to seeing your progress. :salute: