Hi yes I'm looking to make a Round counter for my airsoft gun but I don't really know where to get started I know a little about electronics as I just finished my freshman year in EET and I'm looking for projects to do involving electronics this summer and I thought of a Round counter for my m4 airsoft gun I believe it would need 3 set mode switches but I'm pretty much stumped on the rest if anyone would have a schematic that would be awesome
Does you airsoft gun currently use electronics? How much extra stuff, like batteries and a display and other stuff to go with the Arduino, are you willing to carry around while you operate the airsoft gun?
Paul
I haven't really figured that out yet I am still research it but I think I found a circuit that can be used for the display let me know your thoughts its a 7 segment LED decade counter display
My gun is an AEG and it does use electronics I was thinking for the battery pack I could mount it on my top rail of my gun and and have the display side of my gun
Sure, use it. The switch can be clicked each time you fire. No Arduino needed.
Paul
hmm sweet however i would need something that can sense whenever i put a new mag in it would reset to 300 which is my mag round count Im guessing i would need to use a microcontroller for that
The circuit you proposed only counts up.
Paul
Pin 2 of the counter chip is a Master Reset. A switch in the magazine well could set the counter back to 0. You would have to add another counter chip and decoder to count up to 300.
A 28-pin ATmega328P chip could replace the two counters and three decoders and could count down from 300. It could even flash the display when you get down to your last 50 rounds. It just needs 21 pins of output (7 per digit) and some inputs. Two 8-bit shift registers would work with Arduino pins for the other 5.
hmm so I'm working on schematic that I think might work ill get back to you when I'm done but I'm using 74192 ICs which are up/down BCD counter ICs which I think will work ill send my schematic when its complete
ok ill check into it
so I decided to scrap the circuit and instead use the Arduino to write a program with an LCD display to display a counter no so far I have the LCD displaying "Rounds Remaining" and a button set up so that every time I press it the count will subtract one from 300 but I am stuck right now because every time I press the button the count will count down from 200 but as I lift off the button the count displays counting down from 300 so for example I press once it will display 199 and then I let go and it displays 299 here's my code so far.
What do you expect us to do with a picture of some code that is barely readable? Do you not recall how to post code?
Paul
Select Tools->Auto Format, then Edit->Copy for Forum, then paste your sketch in a reply here.
/******************************************
Website: www.elegoo.com
Time:2017.12.12
******************************************/
/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
LCD RS pin to digital pin 7
LCD Enable pin to digital pin 8
LCD D4 pin to digital pin 9
LCD D5 pin to digital pin 10
LCD D6 pin to digital pin 11
LCD D7 pin to digital pin 12
LCD R/W pin to ground
LCD VSS pin to ground
LCD VCC pin to 5V
10K resistor:
ends to +5V and ground
wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int button1 = 6;
int count = 300;
int press;
int val;
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Rounds Remaining");
pinMode(button1, INPUT);
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(val);
val = digitalRead(button1);
if (val == HIGH)
{
press = count--;
delay(250);
}
lcd.setCursor(0, 1);
lcd.print(press);
}
no I don't this is the first time I'm using the forum my bad I fixed it
You are displaying 'val' (0 or 1) over the first character of 'press' (300 to 0). If you take out those two lines you will just see 'press'.
Note: When 'press' gets down to 99 you will see "990" in the display because the two digits of 'press' will only cover the first two digits of the previous number which was "100". If you follow "lcd.print(press); with "lcd.print(" "); // Two Spaces" the spaces will cover up the end of the old number.
cool ill try it out thanks for the help I'm trying to do most of it by myself but I got stuck thanks ill keep you updated
And surprisingly quickly - many counts for each press - and release - of the button.
If you are using a battery powered airsoft, then the voltage on the motor is applied once for each round fired. So, you could tap off that voltage, making sure that you don't exceed VCC on the arduino input pin. Each voltage pulse is a round fired. No switch needed.
You may need some filtering if the voltage is electrically "noisy", although a simple delay() in the arduino code will essentially isolate (debounce) each voltage pulse.
You could put a switch on the mag chamber that detects a mag change.
If you have a gas blowback gun, then obviously this idea wont work...
ok so I have added a few more things to the code the only issue I have as of now is I programmed a second button to act as the mag release button this button will reset the count to 300 whenever I release the mag it works however whenever the second button is pressed it displays and resets count to 300 but to start the count again I must press the first button twice so basically I press second button (Button2) and it resets count and displays 300 , but button1; which is programmed to count the number of shots I shoot by the trigger on my gun pressing the button, must be pressed twice in order for it to start counting down again from 300. thanks for all your help so far
/******************************************
*Website: www.elegoo.com
*
*Time:2017.12.12
*
******************************************/
/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
* LCD RS pin to digital pin 7
* LCD Enable pin to digital pin 8
* LCD D4 pin to digital pin 9
* LCD D5 pin to digital pin 10
* LCD D6 pin to digital pin 11
* LCD D7 pin to digital pin 12
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int count=300;
int press;
int val; //value stored in arduino
int button1=6;
int Button2=5;
int numbuts=2;
int reset=300;
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Rounds Remaining");
pinMode(button1, INPUT);
pinMode(Button2, INPUT);
}
void loop()
{
val=digitalRead(button1); //reads everytime button is pressed
if(val==HIGH)
{
press=count--;
delay(150);
}
if(count<0)
{
count=0;
}
lcd.setCursor(0, 1);
lcd.print(press);
lcd.print(" ");
val=digitalRead(Button2);
if (val==HIGH)
{
count=reset;
press=reset;
}
}