SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
Old Dec 26, 2014, 01:25 PM
Registered User
Germany, HE, Griesheim
Joined May 2008
182 Posts
Build Log
Simple 4 LED Machine Gun

Nothing special or too complex here.

Just a simple Arduino Pro Mini project to flash 4 x 3W LEDs in some sort of Machine Gun sequence. You can of course reprogram the LEDs to flash as you like, the main point here was to capture the layout in case anyone else can make use of it without having to start from scratch. (well a couple of friends intend to build the same so I though I would post it here for all to share) You should be able to build it easily for < 10$

The FETs are N-Chanel 30V, 5.3A in a SOT-23-3 package (IRLML0030) I got them here

Any generic High Power LEDs will do, I got these as I didn't want any backing plate as they will be on the leading edge or gun post.

The power for the LEDs is taken from a separate regulator set to 3.7V with no current limiting as they wont be on all the time in any case, also no heat sink

Add Resistors, Diodes or what ever else takes your fancy if you want to use a combination of colours.
i.e. if you want to use RED you will need to drop down to about 2.3V etc

Here is the CODE
Code:
 
int A = 2; // A-B Left Pair
int B = 6;
int C = 13; // C-D Right Pair
int D = A3;

#define DEL 40
#define DEL_OFF 50

void setup()
{
  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(C, OUTPUT);
  pinMode(D, OUTPUT);
}

void loop()
{
long l = pulseIn(0, HIGH, 3000); // Use RX as its next to GND,VCC,RX on ProMin END Connector
if ( l < 1500 && l > 0 )
  {
    t41();
    t41();
    delay(250);
    t42();
    t42();
    t42();
    t42();
    delay(250);
    t48();
    t48();
    delay(1000);
  }
}

void t48()
{
    tog();
    tog();
    tog();
    tog();
    tog();
    tog();
    tog();
    tog();
}
void t42()
{
  tog(A, C);
  tog(B, D);
  tog(A, C);
  tog(B, D);
  tog(A, C);
  tog(B, D);
  tog(A, C);
  tog(B, D);
}

void t41()
{
  tog(A);
  tog(B);
  tog(A);
  tog(B);
  tog(A);
  tog(B);
  tog(A);
  tog(B);

  tog(C);
  tog(D);
  tog(C);
  tog(D);
  tog(C);
  tog(D);
  tog(C);
  tog(D);
}

void tog()
{
  digitalWrite(A, HIGH);
  digitalWrite(B, HIGH);
  digitalWrite(C, HIGH);
  digitalWrite(D, HIGH);
  delay(DEL);
  digitalWrite(A, LOW);
  digitalWrite(B, LOW);
  digitalWrite(C, LOW);
  digitalWrite(D, LOW);
  delay(DEL_OFF); 
  delay(DEL_OFF);
  delay(DEL_OFF);
}
void tog(int pin1, int pin2)
{
  digitalWrite(pin1, HIGH);
  digitalWrite(pin2, HIGH);
  delay(DEL);
  digitalWrite(pin1, LOW);
  digitalWrite(pin2, LOW);
  delay(DEL_OFF);
}
void tog(int pin)
{
  digitalWrite(pin, HIGH);
  delay(DEL);
  digitalWrite(pin, LOW);
  delay(DEL_OFF);
}
Its not intended as a lesson in programming so its very simple, just copy and past rather than looping or any other number of optimisations that could be made.

The Arduino is powered directly from the receiver so that I can also make use or the servo signal on the serial RX pin, so no fancy interrupt handling here.

I guess there is lots of info missing for first timers, so if something is not clear then just ask and I will try and add whats missing.

Finally a working system

4 LED Machine Gun (0 min 26 sec)


Have Fun.

.... Simon
Simon Castle is offline Find More Posts by Simon Castle
Last edited by Simon Castle; Dec 26, 2014 at 03:41 PM.
Reply With Quote
Sign up now
to remove ads between posts
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
For Sale Williams Brothers 1/4 Scale Spandau Machine Guns clandestoy Aircraft - General - Miscellaneous (FS/W) 0 Nov 28, 2014 03:13 PM
Mini-HowTo Low Buck DIY 2 gun LED machine guns UNGN Scratchbuilt Indoor and Micro Models 38 Jul 13, 2011 01:35 AM
Discussion LED Machine Gun sjgusmc21 RC Tanks 10 Feb 01, 2009 02:44 AM
Discussion tiger LED machine gun boxerdog RC Tanks 2 Jan 06, 2009 05:10 PM