-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# DIY full auto pneumatic rifle with Arduino | ||
[![MadGyver YouTube](http://alexgyver.ru/git_banner2.jpg)](https://www.youtube.com/channel/UCNEOyqhGzutj-YS-d5ckYdg?sub_confirmation=1) | ||
|
||
## Project description | ||
Full-auto BB pneumatic rifle on Arduino | ||
- 2 shots per second | ||
- Servo powered reload | ||
- Shoots BB 4.5mm airsoft balls | ||
- About 70 balls in magazine | ||
- Muzzle energy 3 Joules | ||
- [Quick start with Arduino](https://learn.sparkfun.com/tutorials/installing-arduino-ide) | ||
|
||
## Download last release | ||
[**Click me**](https://github.com/AlexGyver/EnglishProjects/releases/download/GyverGun/GyverGun.rar) | ||
|
||
## Schemes | ||
![GyverGun](https://github.com/AlexGyver/EnglishProjects/blob/master/GyverGun/drawings/GyverGun_bb.jpg) | ||
|
||
## Components | ||
* Arduino NANO http://ali.pub/2sq5d4 |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions
62
GyverGun/firmware/valve_servo_automatic/valve_servo_automatic.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Created 2016 | ||
by AlexGyver | ||
AlexGyver Technologies | ||
for MadGyver YouTube channel | ||
*/ | ||
|
||
#define MODE 5 | ||
#define TRIGGER 3 | ||
#define VALVE 2 | ||
#define SERVO 4 | ||
|
||
#define STARTPOS 145 // bolt is open | ||
#define STOPPOS 51 // bolt is closed | ||
#define VALVE_DELAY 20 // valve open delay in ms | ||
|
||
#include <Servo.h> | ||
Servo servo; | ||
|
||
byte flag = 0; | ||
byte trigger = 0; | ||
byte set = 0; | ||
|
||
void setup() | ||
{ | ||
pinMode(VALVE, OUTPUT); | ||
pinMode(TRIGGER, INPUT_PULLUP); | ||
pinMode(MODE, INPUT_PULLUP); | ||
|
||
servo.attach(SERVO); | ||
servo.write(STOPPOS); | ||
} | ||
|
||
void shot() { | ||
digitalWrite(VALVE, HIGH); // open valve | ||
delay(VALVE_DELAY); // wait | ||
digitalWrite(VALVE, LOW); // close valve | ||
delay(20); // wait for ball to go away | ||
servo.write(STOPPOS); // open bolt | ||
delay(272); // wait for new ball | ||
servo.write(STOPPOS); // close bolt | ||
delay(272); // wait ball to settle | ||
} | ||
|
||
void loop() { | ||
set = !digitalRead(MODE); | ||
trigger = !digitalRead(TRIGGER); | ||
|
||
if (trigger && !set && !flag) { | ||
shot(); | ||
flag = 1; | ||
} | ||
|
||
if (!trigger && !set && flag) { | ||
flag = 0; | ||
} | ||
|
||
if (trigger && set && !flag) { | ||
shot(); | ||
} | ||
delay(5); | ||
} |