Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGyver committed Oct 7, 2018
1 parent f471ff9 commit bfc595e
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
20 changes: 20 additions & 0 deletions GyverGun/README.md
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 added GyverGun/drawings/GyverGun.fzz
Binary file not shown.
Binary file added GyverGun/drawings/GyverGun_bb.jpg
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 GyverGun/firmware/valve_servo_automatic/valve_servo_automatic.ino
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);
}

0 comments on commit bfc595e

Please sign in to comment.