Cylon Rifle with Lights and Sound
- welshchris77
- Patrol Leader
- Posts: 75
- Joined: Sat Jun 17, 2017 1:35 am
- Contact:
Re: Cylon Rifle with Lights and Sound
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
Video link electronics test
https://www.dropbox.com/s/hr7rp15lb76rm ... 8.mp4?dl=0
Chris Lewis
- Red Eye
- Cylon Empire VIP & BYC.net Gallery Admin
- Posts: 4837
- Joined: Sat May 20, 2006 10:11 am
- Location: Germany
Re: Cylon Rifle with Lights and Sound
Very nice tutorial!
Thank you for sharing.
Thank you for sharing.
"There can be no survivors. So long as one human remains alive the Alliance is threatened."
- Cylon-Knight
- Site Administrator
- Posts: 6420
- Joined: Wed Jul 23, 2008 9:32 pm
- Location: Kansas City
- Contact:
Re: Cylon Rifle with Lights and Sound
EPIC BUILD!!!
"All Baseships are now in range to attack the Colonies."
- welshchris77
- Patrol Leader
- Posts: 75
- Joined: Sat Jun 17, 2017 1:35 am
- Contact:
Re: Cylon Rifle with Lights and Sound
Your very welcome, thanks for the support.
If anyone is interested I can put up the wiring diagram and code needed to do this
Chris Lewis
- Soda Can
- Phalanx Leader
- Posts: 120
- Joined: Wed Jun 10, 2015 2:56 am
- Location: Otaki, New Zealand
- Contact:
Re: Cylon Rifle with Lights and Sound
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.
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.
If anybody can, Soda Can Cylon can.
- Cylon-Knight
- Site Administrator
- Posts: 6420
- Joined: Wed Jul 23, 2008 9:32 pm
- Location: Kansas City
- Contact:
Re: Cylon Rifle with Lights and Sound
PEW PEW!
I love it. #sold
I love it. #sold
"All Baseships are now in range to attack the Colonies."
- Soda Can
- Phalanx Leader
- Posts: 120
- Joined: Wed Jun 10, 2015 2:56 am
- Location: Otaki, New Zealand
- Contact:
Re: Cylon Rifle with Lights and Sound
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
Although in saying that, that could be another good sound file, maybe
If anybody can, Soda Can Cylon can.
- welshchris77
- Patrol Leader
- Posts: 75
- Joined: Sat Jun 17, 2017 1:35 am
- Contact:
Re: Cylon Rifle with Lights and Sound
Ok folks I have put together the wiring diagram, code and parts list
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
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
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
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
Chris Lewis
- FLIGHTLDR SERPENTINE
- Squadron Leader
- Posts: 510
- Joined: Fri Aug 19, 2011 2:18 pm
- Location: Basestar over Mt. Tamalpais
Re: Cylon Rifle with Lights and Sound
Geez. Alot of work there!
"SEARCH FOR WRECKAGE... LEAVE NO SURVIVORS..."
- Soda Can
- Phalanx Leader
- Posts: 120
- Joined: Wed Jun 10, 2015 2:56 am
- Location: Otaki, New Zealand
- Contact:
Re: Cylon Rifle with Lights and Sound
Just a thought, can the leds and driver boards be swapped out with neo pixels?
If anybody can, Soda Can Cylon can.
- welshchris77
- Patrol Leader
- Posts: 75
- Joined: Sat Jun 17, 2017 1:35 am
- Contact:
Re: Cylon Rifle with Lights and Sound
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 projectSoda Can wrote:Just a thought, can the leds and driver boards be swapped out with neo pixels?
Sent from my SM-A310F using Tapatalk
Chris Lewis
- MackUK
- Phalanx Member
- Posts: 86
- Joined: Tue Nov 21, 2017 12:43 pm
- Location: London, UK
Re: Cylon Rifle with Lights and Sound
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
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
- welshchris77
- Patrol Leader
- Posts: 75
- Joined: Sat Jun 17, 2017 1:35 am
- Contact:
Re: Cylon Rifle with Lights and Sound
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 it.
The fabricating of the bits to hold it all in was the trickiest bits to do.
The fabricating of the bits to hold it all in was the trickiest bits to do.
Sent from my SM-A310F using TapatalkMackUK wrote: 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
Last edited by welshchris77 on Wed Sep 19, 2018 10:49 am, edited 1 time in total.
Chris Lewis
- MackUK
- Phalanx Member
- Posts: 86
- Joined: Tue Nov 21, 2017 12:43 pm
- Location: London, UK
Re: Cylon Rifle with Lights and Sound
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!)
I'm sticking with the flash light approach. Seems well within my capabilities.
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!)
I'm sticking with the flash light approach. Seems well within my capabilities.
- Soda Can
- Phalanx Leader
- Posts: 120
- Joined: Wed Jun 10, 2015 2:56 am
- Location: Otaki, New Zealand
- Contact:
Re: Cylon Rifle with Lights and Sound
I'm in exactly the same position as you MackUK, i have never used the arduino boards or programmed anything up as yet.MackUK wrote: ↑Sat Sep 22, 2018 2:52 pmI'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!)
I'm sticking with the flash light approach. Seems well within my capabilities.
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.
If anybody can, Soda Can Cylon can.
Who is online
Users browsing this forum: No registered users and 0 guests