skyone Posted November 10, 2015 Author Report Posted November 10, 2015 there is no need to change the code, i used an arduino pro mini to control the speaker of the helmet and no difficult to program it just get the 5volt version and the USB to RS232 converter to program it the digital pins and pwm pins are same number as arduino nano and get a 5v 1A voltage regulator to power the mini amp and the mp3 player, because, as you can see, it's not supported on that board. Quote
cibcon1 Posted November 10, 2015 Report Posted November 10, 2015 thanks manuel, i will use the mini pro, if i can do make to work i will post my results, do you think i can put diodes in the battery voltage to decrease the voltage to 5v? Quote
skyone Posted November 11, 2015 Author Report Posted November 11, 2015 thanks manuel, i will use the mini pro, if i can do make to work i will post my results, do you think i can put diodes in the battery voltage to decrease the voltage to 5v? it's better you use a voltage regulator that you need only for mp3 amp and mp3 player because arduino mini pro has its own Quote
Marshall[TK] Posted November 11, 2015 Report Posted November 11, 2015 (edited) That's the same route (building a power regulator circuit) I'm taking since I have to power the mp3 and amp with only 3v Sent from my SM-G900F using Tapatalk Edited November 11, 2015 by Marshall Quote
cibcon1 Posted November 11, 2015 Report Posted November 11, 2015 ok, thanks manuel and niccolo, i order a nano board but i will try use the mini i have and post the results when the amp and player arrive a my home, greetings from mexico. Quote
JohnDoe2000 Posted November 13, 2015 Report Posted November 13, 2015 Hi all, I want to build an arduino blaster, too. All parts have been ordered (in three different currencies by the way) and the first parts have arrived. Yesterday I tested the Arduino and edited the blinking program. So far, so good. I have some expericences with raspberry pi but this will be my first arduino project. I think this will be very funny. Greetings from Germany and I wish you a nice arduino weekend 1 Quote
JohnDoe2000 Posted November 16, 2015 Report Posted November 16, 2015 Hi, I cannot download / see the schemes. Is anyone still able to see it? Quote
Chivo Posted November 16, 2015 Report Posted November 16, 2015 Hi, I cannot download / see the schemes. Is anyone still able to see it? I can see it ! Quote
Balders Posted November 17, 2015 Report Posted November 17, 2015 Good luck with your build. I made this with some of my left-over/spare parts: Quote
JohnDoe2000 Posted November 18, 2015 Report Posted November 18, 2015 (edited) Hi all, here is is small update from Germany. I received the first parts of my arduino blaster build. With this parts i wars able to activate the counter nice, isn't it The trigger and reload button are working fine. Now I have to wait for the RGB LED and the sound module. Edited November 18, 2015 by JohnDoe2000 Quote
Bone[501st] Posted November 18, 2015 Report Posted November 18, 2015 Hey Christian, pic's not working ... Try a photobucket account and copy the url in your post. Works guaranteed. Quote
JohnDoe2000 Posted November 18, 2015 Report Posted November 18, 2015 Hey Christian, pic's not working ... Try a photobucket account and copy the url in your post. Works guaranteed. strange. It was uploaded to photobuckt and I can see the pic Quote
skyone Posted November 18, 2015 Author Report Posted November 18, 2015 (edited) strange. It was uploaded to photobuckt and I can see the pic here it is but i can't see neither http://s1377.photobucket.com/user/JohnDoe20001/media/arduino1_zpsj1ezy77g.jpg.html Edited November 18, 2015 by skyone Quote
JohnDoe2000 Posted November 18, 2015 Report Posted November 18, 2015 here it is but i can't see neither http://s1377.photobucket.com/user/JohnDoe20001/media/arduino1_zpsj1ezy77g.jpg.html Damn. I don't get it but I can't upload images. Quote
JohnDoe2000 Posted November 18, 2015 Report Posted November 18, 2015 OK, folks. Do you see it now? I used TinyPic Quote
MOOBOB[TK] Posted November 18, 2015 Report Posted November 18, 2015 I can see it. Sent from my iPhone using Tapatalk Quote
JohnDoe2000 Posted November 19, 2015 Report Posted November 19, 2015 (edited) Hi all, I have an idea and perhaps anyone can help me. I plan to control each LED of the 10 segment display and not only 5 LEDs. At the moment the nano always turns two LEDs off at the same time. For instance after 8 shots the first tow of the LEDs turns off. I want that the first LED turns off after 4 short and the second after another 4 shots. Long, long ago I've learned that I'm able to get 16 states out of 4 bits. So today I googled a little bit and ordered this decoder: http://www.ebay.de/itm/231737470476?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT The main idea is to get more flexibility to control the 10 segment display and you only have to use 4 instead of 5 digital outputs. If my calculations are correct I have the use 150Ohm resistors instead of the 30 Ohm resistors. What do you think about my idea? Does the decoder fit the project parameters? Can anyone help me? Edited November 20, 2015 by JohnDoe2000 Quote
Kiyo Posted November 25, 2015 Report Posted November 25, 2015 Hi Christian, you don't need the multiplexer. The Pins A0 - A5 can also be used as digital pins (only in case that the Arduino copy will work like the original one). Today my WT5001 arrived and i will build a test circuit. I will work on this problem,too. Best reguards from Germany Quote
skyone Posted November 25, 2015 Author Report Posted November 25, 2015 (edited) i avoided to use all pins to control each segment of led bar because so many wires would be hard to fit inside, hope you can do it Edited November 25, 2015 by skyone Quote
JohnDoe2000 Posted November 25, 2015 Report Posted November 25, 2015 (edited) Hi Christian, you don't need the multiplexer. The Pins A0 - A5 can also be used as digital pins (only in case that the Arduino copy will work like the original one). Today my WT5001 arrived and i will build a test circuit. I will work on this problem,too. Best reguards from Germany Hi Nik, a coworker of me told me exactly the same today. I already tested to control one LED of the 10 segment display with the analog input pin A0 and it works very well. So if the extra wire fit in the pipe, I think I implement the other 4 LEDs, too. It wars vary easy to use the analog pin. The syntax ist the same and you don't need to initialize extra libs and you don't have to implement extra methods. Very cool regards, Christian Edited November 25, 2015 by JohnDoe2000 Quote
StriderX[501st] Posted December 2, 2015 Report Posted December 2, 2015 (edited) I've made a somewhat lighter version of Skyone's Arduino Kit: Unfortunately, the sound of the trigger switch is behaving funnily in the sense that it only plays the switch sounds irregularly but without any frequent pattern. This is a Link to the code: http://s000.tinyupload.com/?file_id=58488474502670898710 Any ideas are much appreciated Cheers Edited December 2, 2015 by StriderX Quote
Talltrooper Posted December 12, 2015 Report Posted December 12, 2015 Hello, I have had the same problem, it is caused by sending the single no cycle command all the time, even if it already set. I added a function which checks if a change is needed and only sends the command in this case. Sadly i can´t post the needed lines as my code differs pretty much from the original one. But if its ok and does not create confusion with the original project i can post the whole layout/code here. Regards Quote
StriderX[501st] Posted December 16, 2015 Report Posted December 16, 2015 Hi Rainer, sure, would be cool if you could post the code here or a link to the code file. Cheers Quote
Talltrooper Posted December 17, 2015 Report Posted December 17, 2015 (edited) Hi, So here is the full layout and code, its still pretty much in beta state, especially everything with the counter needs a rewrite. And not everything planed is supported yet. The layout is based on the arduino nano, i used the internal pullups on the arduino board, thats the reason why the whole triggerlogic is inverted, and its missing the trigger resistors. I was not able to get a 2GB SD card so i testet a 8GB SD HC and is does the job flawless, even when the soundmodule descriptions told that you are limited to the small ones. Regards Rainer /* Project "E-11 Blaster" by Evildead this version is compatible with WT-SD MP3 PLAYER created 28 Nov 2015 last modified 12 Dec 2015 This is based on Project "Open Blaster" by TK8177 PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENCE. THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENCE OR COPYRIGHT LAW IS PROHIBITED. BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENCE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. Attribution-NonCommercial You are free: to copy, distribute, display, and perform the work to make derivative works Under the following conditions: Attribution — You must give the original author credit. Non-Commercial — You may not use this work for commercial purposes */ // this constant won't change: const int SelectorSwitch = 6; // WEAPON SELECTOR const int TriggerSwitch = 7; // FIRE const int ReloadSwitch = 8; // WEAPON RELOAD const int LedFireRed = 10; // LED FIRE (RED) const int LedFireBlue = 9; // LED FIRE (BLUE) const int LedFireGreen = 11; // LED FIRE (GREEN) const int LedCounterG10 = 2; // Green Counter Green 10 const int LedCounterG9 = 3; // Green Counter Green 9 const int LedCounterG8 = 4; // Green Counter Green 8 const int LedCounterG7 = 5; // Green Counter Green 7 const int LedCounterG6 = A5; // Green Counter Green 6 const int LedCounterG5 = A4; // Green Counter Green 5 const int LedCounterG4 = A3; // Green Counter Green 4 const int LedCounterR3 = A2; // Green Counter Red 3 const int LedCounterR2 = A1; // Green Counter Red 2 const int LedCounterR1 = A0; // Green Counter Red 1 //Weapon Settings const int Max_Weapons = 4; // Defines Maximum Weapons const int Max_Random_Sound_Arrays = 2; // Defines Maximum Weapons const int Max_Random_Sounds = 13; // Defines Maximum Random Sounds // Variables will change: unsigned long SelectorSwitchHoldT; boolean AllowSelect = false; int RadioHoldDelay = 3000; // Sets the hold delay of Selector Switch for Radio Mode int SelectorState = HIGH; int SelectorSwitch_LastState = HIGH; int TriggerSwitch_LastState = HIGH; int ReloadSwitch_LastState = HIGH; int CurrentPlayMode = 0; int CounterArray[10] = {A0, A1, A2, A3, A4, A5, 5, 4, 3, 2}; // 1---2---3---4 Weapon Number int WeaponMaxAmmoArray[Max_Weapons] = {10, 10, 10, 10}; // Add maximum Weapon ammo here int WeaponTypeArray[Max_Weapons] = { 1, 1, 3, 3}; // Weapon Type 1 = Weapon with Ammo 2 = Weapon unlimited Ammo 3 = Random Sound Player int WeaponFireSoundArray[Max_Weapons] = { 7, 8, 0, 1}; // Number of Fire Sound File or Number of random sound array int WeaponReloadSoundArray[Max_Weapons] = { 3, 3, 0, 0}; // Number of Reload Sound File int WeaponEmptySoundArray[Max_Weapons] = { 5, 5, 0, 0}; // Number of Empty Sound File int WeaponFireLightArray[Max_Weapons] = { 1, 2, 1, 0}; // Number of Fire Lighting int WeaponReloadLightArray[Max_Weapons] = { 1, 1, 1, 1}; // Number of Reload Lighting int WeaponEmptyLightArray[Max_Weapons] = { 1, 1, 1, 1}; // Number of Empty Lighting // Add sound file numbers for random sound player here, each row must have the maximum number of sound files. Not used places need to be 0 int RandomSoundArray[Max_Random_Sound_Arrays][Max_Random_Sounds] = {{22,23,24,25,26,27,28,29,30,31,32,33,34}, { 35,36,37,38,39,40,41,42,43, 0, 0, 0, 0}}; int RandomArray; int RandomTrack; int WeaponAmmoArray[Max_Weapons]; int WeaponSelected = 0; int CounterState = 0; int TriggerState = HIGH; int ReloadState = HIGH; long TrackCounter2 = 0; int var_loop_ammo = 0; int ledStateAmmo = LOW; // ledState used to set the LED long previousMillisAmmo = 0; // will store last time LED was updated long intervalAmmo = 180; // interval at which to blink (milliseconds) void setup() { delay(600); //pause needed to play the track at startup // initialize the switch pins as a input: pinMode(SelectorSwitch, INPUT_PULLUP); pinMode(TriggerSwitch, INPUT_PULLUP); pinMode(ReloadSwitch, INPUT_PULLUP); // initialize the LEDs as an output: pinMode(LedFireRed, OUTPUT); pinMode(LedFireBlue, OUTPUT); pinMode(LedFireGreen, OUTPUT); pinMode(LedCounterG10, OUTPUT); pinMode(LedCounterG9, OUTPUT); pinMode(LedCounterG8, OUTPUT); pinMode(LedCounterG7, OUTPUT); pinMode(LedCounterG6, OUTPUT); pinMode(LedCounterG5, OUTPUT); pinMode(LedCounterG4, OUTPUT); pinMode(LedCounterR3, OUTPUT); pinMode(LedCounterR2, OUTPUT); pinMode(LedCounterR1, OUTPUT); // Turn fire leds off digitalWrite(LedFireRed, LOW); digitalWrite(LedFireBlue, LOW); digitalWrite(LedFireGreen, LOW); // Fill ammo array for(int i = 0; i < Max_Weapons; i++) { WeaponAmmoArray[i] = WeaponMaxAmmoArray[i]; } // initialize serial communication: Serial.begin(9600); randomSeed(analogRead(6)); Serial.write(0x7E); // StartEndCode Serial.write(0x03); // Lenght Serial.write(0xA7); // Volume Command Serial.write(0x1d); // Volume (hexadecimal conversion 1-31 --> 1f = max / 14 = medium) Serial.write(0x7E); // StartEndCode // start sound Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Lenght Serial.write(0xA0); // Play from SD Card Serial.write(0x00); // Highbyte Serial.write(0x01); // track number 01 Serial.write(0x7E); // StartEndCode delay (300); CounterStart (); delay (3600); // random vader welcome TrackCounter2 = random(0,3); // play files random vader voice Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Length Serial.write(0xA0); // Play from SD Card Serial.write(0x00); // Hightbyte if ( TrackCounter2 == 0 ) { Serial.write(0x3c); } if ( TrackCounter2 == 1 ) { Serial.write(0x3d); } if ( TrackCounter2 == 2 ) { Serial.write(0x3e); } if ( TrackCounter2 == 3 ) { Serial.write(0x3f); } Serial.write(0x7E); // StartEndCode } void loop() { //---------------------------------------------------------------------------------------------- SELECTOR BEGIN -------------------------------------------------------------------------- SelectorState = digitalRead(SelectorSwitch); // read the SelectorSwitch input pin: if (SelectorState == LOW && SelectorSwitch_LastState == HIGH) // Selector is pressed { SelectorSwitchHoldT = millis(); // mark the time AllowSelect = true; // allow state changes } if (AllowSelect == true && SelectorState == LOW && SelectorSwitch_LastState == LOW) //Selector remain pressed { if ((millis() - SelectorSwitchHoldT) >= RadioHoldDelay) // for longer than x/1000 sec(s) Enter Radio Mode { Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Lenght Serial.write(0xA0); // Play from SD Card Serial.write(0x00); // Highbit Serial.write(0x40); // track number button sound Serial.write(0x7E); // StartEndCode delay (1500); Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Lenght Serial.write(0xA0); // Play from SD Card Serial.write(0x00); // Highbit Serial.write(0x41); // Track number Serial.write(0x7E); // StartEndCode ChangePlayMode (0); AllowSelect = false; // prevent multiple state changes } } if (AllowSelect == true && SelectorState == HIGH && SelectorSwitch_LastState == LOW) { if ((millis() - SelectorSwitchHoldT) < 700 ) //debounce { ChangePlayMode (0); PlaySelectSound (); WeaponSelected ++; if (WeaponSelected == Max_Weapons) // Last Weapon reached return to first { WeaponSelected = 0; } UpdateCounterLed(); AllowSelect = false; // prevent multiple state changes } } SelectorSwitch_LastState = SelectorState; //----------------------------------------------------------------------------- SELECTOR END --------------------------------------------------------------------------------------- //------------------------------------------------------------------------------- WEAPONS ------------------------------------------------------------------------------------------ //----------------------------------------------------------------------------- Weapon Fires --------------------------------------------------------------------------------------- TriggerState = digitalRead(TriggerSwitch); // shots count - read the pin value and save it if (TriggerState == LOW && WeaponAmmoArray[WeaponSelected] == 0) // Trigger is pulled but weapon is empty { UpdateCounterLed (); if (TriggerState != TriggerSwitch_LastState) // compare the TriggerState to its previous state { PlayEmptySound (); } } if (TriggerState == LOW && WeaponTypeArray[WeaponSelected] == 1 && WeaponAmmoArray[WeaponSelected] > 0) // Trigger is pulled and weapon not empty and weapon have ammo { if (TriggerState != TriggerSwitch_LastState) // compare the TriggerState to its previous state { if (TriggerState == LOW) // if the state has changed, decrement the counter { WeaponAmmoArray[WeaponSelected] = (WeaponAmmoArray[WeaponSelected] -1) ; UpdateCounterLed (); PlayFireSound (); PlayFireLight (); } } } if (TriggerState == LOW && WeaponTypeArray[WeaponSelected] == 3) // Trigger is pulled and weapon is in random soundfile mode { if (TriggerState != TriggerSwitch_LastState) // compare the TriggerState to its previous state { if (TriggerState == LOW) { PlayRandomSound (); PlayFireLight (); } } } TriggerSwitch_LastState = TriggerState; // save the current state as the last state, for next time through the loop if (WeaponAmmoArray[WeaponSelected] == 0) // Check if weapon is empty and let red led blink { CounterStatusEmpty (); } //---------------------------------------------------------------------------- Weapon Reloads ----------------------------------------------------------------------------------------- ReloadState = digitalRead(ReloadSwitch); if (ReloadState == LOW && WeaponTypeArray[WeaponSelected] == 1) // No need to reload a weapon without ammo { PlayReloadSound (); CounterReload (); WeaponAmmoArray[WeaponSelected] = WeaponMaxAmmoArray[WeaponSelected] ; } } //--------------------------------------------------------------------------------------- SOUND FUNCTIONS ------------------------------------------------------- void ChangePlayMode (int PlayMode) { if (CurrentPlayMode != PlayMode) { Serial.write(0x7E); // StartEndCode Serial.write(0x03); // Lenght Serial.write(0xA9); // Set Play Mode Serial.write(0x00+PlayMode); // Set Play Mode to 0 No Cyle or 1 Cycle Serial.write(0x7E); // StartEndCode CurrentPlayMode = PlayMode; } } void PlaySelectSound () { Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Length Serial.write(0xA0); // SDCard Playback Serial.write(0x00); // Highbyte Serial.write(0x04); // Lowbyte Track 4 Serial.write(0x7E); // StartEndCode } void PlayFireSound () { Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Length Serial.write(0xA0); // SDCard Playback Serial.write(highByte(WeaponFireSoundArray[WeaponSelected])); // Highbyte Serial.write(lowByte(WeaponFireSoundArray[WeaponSelected])); // Lowbyte Serial.write(0x7E); // StartEndCode } void PlayEmptySound () { Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Length Serial.write(0xA0); // SDCard Playback Serial.write(highByte(WeaponEmptySoundArray[WeaponSelected])); // Highbyte Serial.write(lowByte(WeaponEmptySoundArray[WeaponSelected])); // Lowbyte Serial.write(0x7E); // StartEndCode delay(500); } void PlayReloadSound () { Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Length Serial.write(0xA0); // SDCard Playback Serial.write(highByte(WeaponReloadSoundArray[WeaponSelected])); // Highbyte Serial.write(lowByte(WeaponReloadSoundArray[WeaponSelected])); // Lowbyte Serial.write(0x7E); // StartEndCode } void PlayRandomSound () { RandomArray = WeaponFireSoundArray[WeaponSelected]; for(int i = 0; i < (Max_Random_Sounds); i++) { if (RandomSoundArray[RandomArray][i] == 0) { RandomTrack = random (0, (i -1)); break; } if (i == (Max_Random_Sounds -1)) { RandomTrack = random (0, (Max_Random_Sounds -1)); break; } } Serial.write(0x7E); // StartEndCode Serial.write(0x04); // Length Serial.write(0xA0); // SDCard Playback Serial.write(highByte(RandomSoundArray[RandomArray][RandomTrack])); // Highbyte Serial.write(lowByte(RandomSoundArray[RandomArray][RandomTrack])); // Lowbyte Serial.write(0x7E); // StartEndCode } //----------------------------------------------------------------------------------- LIGHT FUNCTIONS ------------------------------------------------------- void PlayFireLight () { switch (WeaponFireLightArray[WeaponSelected]) { case 1: // E-11 Blaster delay(30); // pause to wait mp3 start digitalWrite(LedFireRed, HIGH); digitalWrite(LedFireBlue, HIGH); digitalWrite(LedFireGreen, HIGH); delay(1); digitalWrite(LedFireBlue, LOW); digitalWrite(LedFireGreen, LOW); delay(80); // partial lenght of sound digitalWrite(LedFireRed, LOW); delay(250); // pause to wait the sound finish break; case 2: // E-11 Stun delay(30); // pause to wait mp3 start analogWrite(LedFireRed, 255); analogWrite(LedFireBlue, 255); analogWrite(LedFireGreen, 255); delay(30); analogWrite(LedFireRed, 0); analogWrite(LedFireGreen, 0); analogWrite(LedFireBlue, 0); delay(30); analogWrite(LedFireRed, 255); analogWrite(LedFireBlue, 255); analogWrite(LedFireGreen, 255); delay(30); analogWrite(LedFireRed, 0); analogWrite(LedFireGreen, 0); analogWrite(LedFireBlue, 0); delay(30); analogWrite(LedFireBlue, 255); delay(50); analogWrite(LedFireBlue, 0); delay(40); analogWrite(LedFireBlue, 255); delay(30); // fade out from max to min in increments of 5 points: for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { analogWrite(LedFireBlue, fadeValue); delay(10); } delay(100); // pause to wait the sound finish break; default: break; } } //------------------------------------------------------------------------ COUNTER FUNCTIONS ------------------------------------------------------- void UpdateCounterLed () { CounterState = ((WeaponAmmoArray[WeaponSelected]*10) / WeaponMaxAmmoArray[WeaponSelected]); for(int i = 0; i < CounterState; i++) { digitalWrite(CounterArray[i], HIGH); } for(int i = 9; i >= CounterState; i--) { digitalWrite(CounterArray[i], LOW); } } void CounterStatusEmpty () //LED BAR - BLINKING END AMMO { // blinking led start unsigned long currentMillisAmmo = millis(); if(currentMillisAmmo - previousMillisAmmo > intervalAmmo) { previousMillisAmmo = currentMillisAmmo; if (ledStateAmmo == LOW) ledStateAmmo = HIGH; else ledStateAmmo = LOW; digitalWrite(LedCounterR1, ledStateAmmo); var_loop_ammo++; } // blinking led END } void CounterStart () { for(int i = 0; i < 9; i++) { digitalWrite(CounterArray[i], HIGH); delay(30); } digitalWrite(CounterArray[9], HIGH); } void CounterReload () // delay total 2700 RELOAD AMMO LED BAR { for(int i = 9; i >= 0; i--) { digitalWrite(CounterArray[i], LOW); } delay(200); for(int i = 0; i < 5; i++) { digitalWrite(CounterArray[0], HIGH); delay (300); digitalWrite(CounterArray[0], LOW); delay (200); } CounterStart (); } Edited December 19, 2015 by Talltrooper 2 Quote
Talltrooper Posted December 19, 2015 Report Posted December 19, 2015 Upper post have been updated with new code for the Counter Regards Rainer Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.